community
cancel
Showing results for 
Search instead for 
Did you mean: 

Alteryx designer Discussions

Find answers, ask questions, and share expertise about Alteryx Designer.
New Data Science Blog

Check out the latest post: All Models Are Wrong

READ MORE
SOLVED

regex_match with ()

Asteroid

in a formula tool, I have this:

 

if REGEX_Match([nameplate],'C-MAX|Focus|FocusRS|MKZ|Taurus') then 0 else [Wheelbase] endif

 

but if in the [nameplate] field, there is Focus (NA) and it's getting ignored in this formula tool.  I've tried the following and none of it works:

 

Focus (NA)

"Focus (NA)"

`Focus (NA)`

'Focus (NA)'

Focus*

 

How do i convince regex_match to match on something with a space and ()?  thanks

 

 

 

 

 

Alteryx Partner

Hi becki,

 

Theres a couple of ways to approach this. If you waont to capture all things that have "Focus" followed by any number of characters, you could use:

 

if REGEX_Match([nameplate],'C-MAX|Focus\s.*|FocusRS|MKZ|Taurus') then 0 else [Wheelbase] endif

 

The "\s" indicates that there should be one whitespace in that location. The "." character says: "any type of character", and the "*" says, 0 or more of the previous character.

 

Let me know if this isn't working.

 

Cheers!

 

Highlighted
Quasar

Hi @becki

 

The issue with the brackets are that these are metacharachters. This means that they have a special meaning in Regex. To get around this you need to escape them - this turns them back into their literal character - i.e. a bracket instead of a start to a group. The way to escape something is to put a \ in front of it.

 

Here is an example for yours. The \s represents a space.

 

regex.PNG

 

Hope that helps!

Katrin

Asteroid

perfect, thanks!

Asteroid

thanks.  that worked too!

Labels