Regex extractX global flag
Hello,
I am trying to extract 1-N regex matches. This is my code:
extractx("Hello, this is {first} and this is {second} match...", "(\{\S+\})+", "g", "$1;$2");
I would expect result:
{first};{second}
But my result is:
{first};undefined
I know that I can use more brackets separately, but this doesn't work if I do now know exact number of matches in advance.
Please, do you have any solution for that?
Thanks!
Filip
2 replies
-
My suggestion would be to somehow use the
replacex()
function because the "g" flag works with it. The "g" flag does not work with theextractx()
function... -
While I'm not an expert, it's easy enough to search on the topic. I don't think their implementation is ideal and doesn't allow for using the "g" flag without using groups...
I think extractx(string, regular_expression, flags) should be allowed and in the case of extractx(string, "pattern", "g") you would get an array of matches. Some examples I've seen on the forum suggest that extractx(string, "pattern", "g", "$0") should return all matches, but it doesn't work.
Content aside
- 4 yrs agoLast active
- 2Replies
- 697Views