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 very | Blue Sea is always | blue unless its orange when its not | BLUE 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
Solved! Go to Solution.
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!
You can also tokenize on this,
(.+?)\s+(?=blue|$)
No need to worry about the (?i) - you can just have the case insensitive box ticked.
Interesting @PhilipMannering
Running this it picks up the first two blues but the all in caps BLUE it fails
Wow, thanks for that. Question over the regex part, whats the pipe for in "(?=blue|$)"
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".
Perfect, thank you @PhilipMannering