Bring your best ideas to the AI Use Case Contest! Enter to win 40 hours of expert engineering support and bring your vision to life using the powerful combination of Alteryx + AI. Learn more now, or go straight to the submission form.
Start Free Trial

Alteryx Designer Desktop Discussions

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

Regex: Remove everything before special characters

HW1
9 - Comet

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 *?

5 REPLIES 5
apathetichell
20 - Arcturus

regex_replace([Product],".*(\*\*\*.*)","$1")

HW1
9 - Comet

Can you please help me understand this regex?

apathetichell
20 - Arcturus

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!

HW1
9 - Comet

Right!

Now I see how the $1 is used.
Thanks!

Qiu
21 - Polaris
21 - Polaris

@HW1 
Try this website

https://regex101.com/
It will give the detailed explaination about your Regex.

Capture1.PNG

Labels
Top Solution Authors