Start Free Trial

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Including Double and Single quotes in Regex_Match

Kaisa77
6 - Meteoroid

Hello, I'm trying to find special characters in the field using Regex_Match. I need to check double and single quotes as well, but I can't figure out the format to include them. 

Here's my formula:

REGEX_Match([ALL], ".*[\@!#%^*?$~+&].*")

 

This is what I want:
REGEX_Match([ALL], ".*[\@!#%^*?$~+&"'].*") i.e. add checks for " and ' as well. 

I tried using """ for " as well as ' " ' and many other combinations, but nothing works. 

Please help :)

10 REPLIES 10
apathetichell
20 - Arcturus

how about something like:

REGEX_Match([ALL], ".*[\'\@!#%\^\*\?\$~\+\&].*") OR REGEX_Match([ALL], '.*["\\@!#%\^\*\?\$~\+\&].*')

 

You origina logic needs to mark off other special characters--- if you have a universe of characters you do want - maybe you can use [] to include them and a ! sign?

Kaisa77
6 - Meteoroid

I just realized that I can actually include a single quote similar to other characters, but I'm still struggling with the double quotes. 

apathetichell
20 - Arcturus

see my suggestion. use an OR statement so ---- ' in your first statement - add an

 

OR regex_match([field],'"') to your formula.

 

There are other ways - but this is the most straightforward. you have ' in your doublequote term and double quotes in a standalone single quote term. 

Kaisa77
6 - Meteoroid

This worked, thank you!

apathetichell
20 - Arcturus

Cool - can you mark my suggestion as a solution?

OllieClarke
16 - Nebula
16 - Nebula

@Kaisa77 if you want to include both, then you just need to concatenate 2 strings, so:

REGEX_Match([ALL], ".*[\@!#%^*?$~+&'"+'"'+"].*")

Where I put the single quote in the first string (enclosed by double quotes), then concatenate a double quote string (enclosed in single quotes), then concatenate the rest of the formula (enclosed in double quotes).

 

Hope that helps,

 

Ollie

Kaisa77
6 - Meteoroid

I'm sorry, I thought it worked, but then I ran on the full set and it didn't work :(

Kaisa77
6 - Meteoroid

This solution definitely worked, but to avoid rerunning everything I only separated " and ' checks like this: 

REGEX_Match([ALL], ".*[\'"+'"'+"].*")

 

and it worked, but I can't figure out how to ONLY check the double-quotes.
Could you please help me with that too? :)

apathetichell
20 - Arcturus

only check for double quotes? regex_match([field],'.*".*') would flag anything with at least one "

Labels
Top Solution Authors