0

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

null
    • Sean
    • 4 yrs ago
    • Reported - view

    My suggestion would be to somehow use the replacex() function because the "g" flag works with it. The "g" flag does not work with the extractx() function...

     

    https://ninox.com/en/forum/ideas-and-suggestions-5abb9f4f45eda7ea1e75ed02/please-fix-the-extract-function-so-flags-will-work-5e25440845dcf70528699a3e

    • Sean
    • 4 yrs ago
    • Reported - view

    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.