ACT NOW: The Alteryx team will be retiring support for Community account recovery and Community email-change requests Early 2026. Make sure to check your account preferences in my.alteryx.com to make sure you have filled out your security questions. Learn more here
Start Free Trial

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
RÉSOLU

Regex Error (but okay in Regex101)

Bobbins
Astéroïde

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 RÉPONSES 16
Bobbins
Astéroïde

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
Astéroïde

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
Astéroïde

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
Astéroïde

Perfect, thank you @PhilipMannering 

Étiquettes
Auteurs des meilleures solutions