Hello everyone,
I’m applying this regex expression to detect commas that are not in between double quotes in my text variable and I’m getting weird results on the app that don’t make sense to me:
“,(?=(?:[^"]"[^"]")[^"]$)”
when I use this expression on a MATCHES_REGEX formula, I get a TRUE result.
when I use this expression on a SPLIT formula, the text does not get split
For example:
pageVars.text = “a, b, c”
MATCHES_REGEX(pageVars.text, “,(?=(?:[^"]"[^"]")[^"]$)” ) results True
SPLIT(pageVars.text, “,(?=(?:[^"]"[^"]")[^"]$)” ) results [“a, b, c”]
Well, if the MATCHES_REGEX, the text should have been split by the SPLIT function, shouldn’t it?
I found this regex on
I tested on https://regex101.com/ and it matched the commas there.
Any help is appreciated.
Thanks,
Ricardo
Hi
The link you provided gives you this regex “,(?=(?:[^"]"[^"]")[^"]$)” that only find comas outside of double quotes, that example text and this regex you will never get any splitting because all the commas are inside double quotes.
So if you use this:
text = “a, b, c”
result = [“a, b, c”]
but if you use this:
text = ’ “using, inside this”, “again using , inside this” ’
result = [“using, inside this”, “again using , inside this”]
because it only catches that outside coma between the first string and the second one.
Hope that this helped you
Hi Paulo, thanks for your response.
I tried reproducing it. But I do not think that’s what is happening.
For example:
if what you are saying was true, if the text was:
text = “data1, "data, 2", data3”
the comma between data and 2 would be detected and split.
However that’s not what I’m seeing on the app
the result for my text variable, after “,(?=(?:[^"]"[^"]")[^"]$)” is:
text = [“data1, "data, 2", data3”]
a list with one text only.
Also, If i try to skip the first character of
text = “data1, "data, 2", data3”
the text that is processed is: “ata1, "data, 2", data3”
double quotes don’t seem to be counted in such cenario.
Regards,