About EasyMorph Tutorials & Examples Web-help

Error extracting regex groups with commas

Hello,

When extracting data with regex, I’ve found a case where the regex action does not seem to work correctly. This is my regex pattern: ((?:\d+,?[.]?\d*)-?(?:\d*,?[.]?\d*)) ?W

Basically what this does is extract a certain pattern before the letter “W” as a capture group. Here’s an example from regex101, where you can see the full match (including the W) and the capture group (without the W):

In Easymorph, it’s working correctly except for the patterns that have a comma. In this case, for some reason the comma is being deleted. Here is a table from easymorph, in column “Descripción” there’s the text where the regex is applied to. There’s two rows for each value: in the first row the full match is displayed, and in the second group the capture group is displayed. Notice that it works ok if there is no comma in the match (100W goes to 100, 4W goes to W…) however, in the case of 6,2W, it becomes 62 instead of 6,2, which would be the correct value:

Why can this be happening?

Thanks a lot,

Roberto

It’s a known issue in EasyMorph. Currently it treats commas as a thousand separator and ignores them. We will fix this behavior in the next release.

Meanwhile, you can work around it by replacing commas with a special character (e.g. pipe “|”) using the replace() function before regex matching, and then replacing the character back with a comma after regex matching.

1 Like
To learn more about EasyMorph visit easymorph.com.