Alteryx Designer Desktop Discussions

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

Regex Error (but okay in Regex101)

Bobbins
8 - Asteroid

Hello,

Text String;

"The very Blue Sea is always blue unless its orange when its not BLUE sea"

The idea is to split on every "blue" regardless of case to give:

The veryBlue Sea is alwaysblue unless its orange when its notBLUE sea


This works in Reg101 but not in Regex as to parse it gives the error: "Error: Nothing to parse. Enter a complete expression."

Code is:
(?i)\s+(?=\bblue\b)

Thank you

16 REPLIES 16
Bobbins
8 - Asteroid

The example represents a real life scenario for me where I need the case of the lettering to be kept. If i didn't, then your example would have been perfect. Your solution is valid for someone whom case will not matter and I thank you for noting how it could be done this way. If i can select multiple solutions i will do!

PhilipMannering
16 - Nebula
16 - Nebula

You can also tokenize on this,

(.+?)\s+(?=blue|$)

 

No need to worry about the (?i) - you can just have the case insensitive box ticked.

Bobbins
8 - Asteroid

Interesting @PhilipMannering 

Running this it picks up the first two blues but the all in caps BLUE it fails

PhilipMannering
16 - Nebula
16 - Nebula

So it does..

 

This looks about right,

PhilipMannering_0-1643232115666.png

 

Bobbins
8 - Asteroid

Wow, thanks for that. Question over the regex part, whats the pipe for in "(?=blue|$)"

 

 

PhilipMannering
16 - Nebula
16 - Nebula

The pipe | means "or". And $ means end of line.

So in this case we're saying that we want to capture text up until a "blue" or "end of the line".

 

Thinking about it, you'll want to use (?=\bblue\b|$) to split on blue as a word...if you didn't want to split on, say, "bluetooth".

Bobbins
8 - Asteroid

Perfect, thank you @PhilipMannering 

Labels