How can I remove everything before "***"?
I have data coming in in the format:
Product |
- *** 1100L WHEELED BIN RECYCLING |
- *** SIZE 4 BIN |
4 *** SIZE 4 BIN RECYCLING |
= *** 1100L WHEELED BIN RECYCLING |
I want the data to be :
Product |
*** 1100L WHEELED BIN RECYCLING |
*** SIZE 4 BIN |
*** SIZE 4 BIN RECYCLING |
*** 1100L WHEELED BIN RECYCLING |
How can I use
Regex_Replace
or
Regex Trim?
to remove everything before *?
Solved! Go to Solution.
regex_replace([Product],".*(\*\*\*.*)","$1")
Can you please help me understand this regex?
Totally!
Here's how to see it:
the first part is .* - this matches everything any number of times (including zero).
next we create our marked group with the open parenthesis. Now since the character string you are looking for is *** you can't just search for that in regex since "*" is a special character. You need to use the exit character "\" to signify that you are searching for a character and not using a special a special regex character - thus we have \*\*\*. We've placed this in our marked group along with the ubiquitous ".*" - which matches everything that comes after the \*\*\*. We then close the parenthesis.
The next parameter in regex_replace is telling it what to replace with - and we're telling it to replace it with the first marked group ie $1. If it was the second marked group (parenthesis unit) it would be $2. Or $2,$1 or any combination thereof.
At least that's how I understand it - so hope that that helps!
Right!
Now I see how the $1 is used.
Thanks!