I have a column of strings, and I want to use a regex to find commas or pipes in every cell, and then make an action. I tried this, but it doesn't work (no syntax error, just doesn't match neither commas nor pipes).
if(value.contains(/(,|\|)/), ...
The funny thing is that the same regex works with the same data in SublimeText. (Yes, I can work it there and then reimport, but I would like to understand what's the difference or what is my mistake).
I'm using Google Refine 2.5.
Since
value.match
should return captured texts, you need to define a regex with a capture group and check if the result is not null.Also, pay attention to the regex itself: the string should be matched in its entirety:
So, add
.*
before and after the pattern you are looking inside a larger string: