This site uses different types of cookies, including analytics and functional cookies (its own and from other sites). To change your cookie settings or find out more, click here. If you continue browsing our website, you accept these cookies.
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
Solved! Go to Solution.
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!
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.
Hope that helps!
Katrin
perfect, thanks!
thanks. that worked too!
Hi Guys,
This was very helpful, thanks for sharing. However, I'm kind of stuck on the next step. I'm trying to select multiple strings in a column which have ().
American Depository Receipt (ADR)
Corporate Bond
Government Bond
Global Depository Receipt (GDR)
REGEX_Match([Security Type], 'American Depository Receipt\s\(ADR\)\Corporate Bond/Government Bond\Global Depository Receipt\s\(GDR\)') I'm trying to use this formula to filter these strings but it isn't working. Is there any other way I can do this?
If I have not understood you wrong, use below in a formula tool against the field and verify.
Create a Boolean field and test the inputs.
True is 1 False is 0
IF REGEX_Match([Security Type], "American Depository Receipt\s\(ADR\)") THEN 1
ELSEIF REGEX_Match([Security Type], "Corporate Bond") THEN 1
ELSEIF REGEX_Match([Security Type], "Government Bond") THEN 1
ELSEIF REGEX_Match([Security Type], "Global Depository Receipt\s\(GDR\)") THEN 1
ELSE 0
ENDIF