Comma Separation That Excludes Number Value

Hi. I am looking for a way to replace "," in a field with ", " and not adding a ", " to a numeric value at the same time. For instance, if I were to use a Replace with function for "1,000 Labels per Roll" the result would be "1, 000 Labels per Roll". Is there a way to do this in EM?

The following screenshot contains the Value and what the Updated Value should be. I also attached the file for reference as well. Thanks.


EM Sample.xlsx (9.1 KB)

Replace everywhere, and then for ", " between digits replace back with ",".

Here is an example:
comma-replacement.morph (6.7 KB)

Another option is to use regex.

PS. Special thanks for the prepared sample data.

Thank you so much. This type of solution with assist with enhancing the quality of our Descriptions.
Always happy to include a sample dataset!

You could also try calculating a new column by applying a regex replace.

regexreplace([Value], ", ", "(?<=\D),(?=\S)")

  • (?<=\D): Ensures the preceding character is not a digit (non-numeric context).
  • ,: Matches the literal comma.
  • (?=\S): Ensures the next character is not a whitespace (avoids adding extra spaces).
2 Likes