What is the Expression method to replace a string character - e.g. a Comma in a number field

Hi All,

Good Day.
I have encountered an issue to use the String expression to replace a character - say a ‘comma’.

For instance, in a number field with a value of 123,456.00, I would like to remove the comma and update the value to 123456.00.

I have tried the string.replace(’,’ , ‘’) approach as described in the Axure RP documentation https://docs.axure.com/axure-rp/reference/math-functions-expressions/#_string_replacesearchvalue-newvalue

However, it was not working as the way as I anticipated. To give everyone a context about my issue, you may check out the prototype that I have put up via the following link:
Link to Demo for removing comma

Or, you may download the sample file here
Issue_ReplaceString.rp (48.4 KB)

I appreciate that someone can shed some light on how to work around this.

Thank you.

Look closely at your expression: it’s using “smart” quotes. You need to use regular single or double quotes " or ’ not ‘’

1 Like

Hi nkrisc,

Thanks for pointing out the “smart” quotes issue! Now I only realized that the default settings for my machine’s keyboard have Smart Quotes & Dashes being turned on. This has created a problem each time when I enter the quote symbol, and it got “auto-corrected” unknowingly!

Should anyone ever encounter this issue, all you need to do is to go the Systems > Keyboard Settings> Text, unchecked the Smart Quote feature, if you are on a macOS device. (See above figure)

Again, thank you for your help @nkrisc !

1 Like

Hi LinChou!

Don’t blame yourself. Axure should be converting smart quotes to normal quotes anywhere it expects an expression. This is especially true now that smart quotes are now the default on MacOS. Imagine if Visual Studio had this problem!

1 Like

Hi @josephxbrick

Thanks for the words. You are right that we don’t encounter such an issue in other products’ Code Editor before. @axure should resolve this issue.

Also, it would be great that @axure can provide a context-aware expression completion feature in its value Editor (fx) environments that help to speed up the process when we are drafting an expression. For instance, by adding a period (.) to an instance/ variable name, the expression window would appear as I type while narrowing down to the closest function I need.

It is counter-intuitive that after I have declared a Local Variable - such as LVAR1, the following expression that I appended would start from LVAR1.LVAR.toFixed(), instead of LVAR1.toFixed().

Cheers!

Guys! I LITERALLY spent 3 hours yesterday troubleshooting this whole thing!! It was driving me crazy! I was using the facetfilters.rp file you had posted, josephxbrick (BTW, thanks!). So, I’d modify the expressions to fit my variables and my friggin’ Mac would switch them out, without REALLY noticing! GA! What a PITA!

I agree though, this PROBABLY should be part of the core, IF Axure is going to be looking for the regular quotes.

Bottom line, I discovered it, and made the mod… THEN found this forum post. Thanks all!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.