Heidar
January 2, 2023, 9:52pm
1
In order to correctly display the letter s in a special font within a linguistic app, I need to replace all the letters s by the well-known $ symbol. Unfortunately, I always get an error message. The app works fine though when I change the $ symbol into any other letter or symbol. Is there a useful workaround for this problem? Thank you in advance.
TIMAI2
January 2, 2023, 10:01pm
2
Try "escaping" the dollar sign with a \
1 Like
Heidar
January 2, 2023, 10:04pm
3
It works! You’re awesome; thank you very much!
I've made a note for someone to fix this here:
opened 03:50PM - 03 Jan 23 UTC
bug
help wanted
status: forum
affects: ucr
priority: low
**Describe the bug**
[From the forum](https://community.appinventor.mit.edu/t… /replace-certain-letters-by-symbol/73564?u=ewpatton): the `replace all text` block will throw an error if the replacement string contains `$`. This is because the string replacement logic will try to substitute in regex capture groups provided in the input pattern. However, we call `Pattern.quote` on the input string to make sure that users don't accidentally trip over regex, so the semantics of the `$` in the replacement cannot ever be satisfied. According to [Java's String.replaceAll method](https://docs.oracle.com/javase/7/docs/api/java/lang/String.html#replaceAll(java.lang.String,%20java.lang.String)), we can use Matcher.quoteReplacement to get similar behavior to how we use Pattern.quote to protect against regex semantics.
**Affects**
<!--
Please check off the part of the system that is affected by the bug.
-->
- [ ] Designer
- [ ] Blocks editor
- [x] Companion
- [x] Compiled apps
- [ ] Buildserver
- [ ] Debugging
- [ ] Other... (please describe)
**Expected behavior**
Users should be able to replace with a `$` without having to escape it with `\`.
**Steps to reproduce**
An example is provided in the linked forum post.
ABG
January 3, 2023, 6:00pm
15
Would the number '5' work for you?
That would avoid the bug and its workaround bandage.
Heidar
January 3, 2023, 6:56pm
16
The problem has already been solved thanks to TIMAI2’s fabulous suggestion.
Thank you nonetheless!
ABG
January 3, 2023, 8:07pm
17
Here is another workaround that should be immune from future changes to the inner workings of that replace block:
2 Likes
Heidar
January 4, 2023, 5:30pm
18
Great idea! Thank you very much!
system
Closed
January 11, 2023, 5:31pm
19
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.