Expression REGEX_(MATCH|REPLACE) documentation

Not sure if this belonged in “Product suggestions” or “Support” so I put it in General…

I couldn’t find much documentation in community or the Knowledge Base on what the options are for the “modifiers” for the REGEX functions in the expression editor.

image

This appears to be a list of options, someone please let me know if I’m wrong. @L_Churchill if you are still updating the Knowledge Base articles, will you please add a link to the REGEX search modifier options?

Thanks, Al

Hey Al,

This is a great question and call-out to improve our documentation here!

In terms of a good resource for REGEX search modifier options, this is a good link: RegExp() constructor - JavaScript | MDN. Since the expression functions in Tulip are using the out of the box Reg Exp constructor, the modifiers are the flags listed in this JS documentation.

We will work on updated the Knowledge Base to include this as well :slight_smile:

Just wasted 1h trying to figure out how to make global regex matches work… then I finally found this post. I was about to throw the towel. Please update the Knowledge Base and more importantly the editor hint! Particularly why there is the additional “\” at the beginning of the second match string :sleeping:

Hi Sebastian,

I’m glad this thread helped you but sorry it took so long to find it!

@jakerigos did make some updates to the KB article after this post: Full List of Expressions in the Analytics Editor but are these not sufficient? If not, please let us know!

The call out here to update the expression editor hint is great - I’ll make a ticket for the product team to look at that.

1 Like

I have run into several cases where REGEX_REPLACE did not work as expected. For example, if you try to use the example that is provided, you will get “Hello There” instead of the expected result of “There Hello”.

image

We either need better documentation and the example fixed.

1 Like

The issue here is, you must escape any \ with a second \

So this would work:
regex_replace('Hello There', '(\\w+)\\s(\\w+)', '$2 $1')

But you are right. That is not well documented.

2 Likes

I myself was struggling to figure this out :sweat_smile: Thanks Thorsten!

I will note this to the team to fix the example in the expression editor and to update our KB article with more details here, as it is important to note that when writing regex inside a string, you must escape the backslashes(\) because JavaScript treats \ as an escape character in string literals.

1 Like

Found this as well - go vote on it :slight_smile: Add Unique Coloring for Escape Character Backslash

1 Like

Thank you Thorsten! I have always been able to find a work around, but this will help in the future.