Alteryx Designer Desktop Discussions

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

Regex Syntax Failure

Biswarun
8 - Asteroid

I am curious about why "\w+|\s+" matches "Redinger" but fails to match "Matest Benger".

6 REPLIES 6
grazitti_sapna
17 - Castor

@Biswarun, the reason your syntax only captures Redinger but not Matest Benger is due to your regex syntax \w+|\s+ it means that it will either capture a word or a space where or is represented by "|" (pipe).

In order to capture both the words, you can try this.

grazitti_sapna_0-1657611252233.png

 

I hope this solves your doubt.

 

Thanks!

Sapna Gupta
DataNath
17 - Castor

\w+ looks for the presence of one of more word characters, | indicates or and then \s+ indicates the presence of one or more spaces and so you’re asking it to return a string that is one or the other. In ‘Redinger’ there’s only word characters so that’ll return fine but the other string goes word > space > word and so you’d have to define the pattern in that order (something like \w+\s+\w+) instead of just saying the whole string is just one or the other.

Biswarun
8 - Asteroid

That's nice but I am trying to match any generic string of the type "Word Word Word ...."

 

Test cases "Arnold Arn Besrf Degy" and "Asd Fgt Tghy Uigh Hjju" shall return true but "Arnol #$ Df" shall return false.

 

The regex mentioned by me, if run in global mode, can catch the entire string but I so not know how to enable such in Alteryx.

grazitti_sapna
17 - Castor

@Biswarun, give this a try.

 

I think this regex will solve your purpose

[a-z\s]+

 

grazitti_sapna_0-1657625488440.png

 

 

Thanks!

Sapna Gupta
PhilipMannering
16 - Nebula
16 - Nebula

@grazitti_sapna I think you mean,

 

[a-zA-Z\s]+

 

Although with Case Insensitive ticked, you might as well just have,

[a-z\s]+

 

grazitti_sapna
17 - Castor

@PhilipMannering, thanks for noticing that.

 

Thanks!

Sapna Gupta
Polls
We’re dying to get your help in determining what the new profile picture frame should be this Halloween. Cast your vote and help us haunt the Community with the best spooky character.
Don’t ghost us—pick your favorite now!
Labels