cancel
Showing results for 
Search instead for 
Did you mean: 
Announcement | Alteryx Connect is now generally available! Find, understand, and trust all relevant information in your organization. Find out more.

Regex to subset a string between " - "

SOLVED
Highlighted
rev
Meteor

So, I have the following data in a single column:

10-Junior-32

101-Senior-23

102-Senior Pres-34

01-Senior Pres XYZ-30

 

and this is the desired output:

Junior

Senior

Senior Pres

Senior Pres XYZ

 

I am trying to subset the string between the "-".

Since neither the position is set or the number of characters to take out.

I can only think of regex which could subset the string between "-" and put it into a new column. That is the desired output.

 

Any thoughts or suggestions would be highly appreciated. Thanks!!!

  • Dynamic Processing
  • Regex
Pulsar
Pulsar

Hi @rev,

I believe this should work: a formula tool creating your new column using the expression...

REGEX_Replace([f1], ".*-(.*)-.*", "$1")

... where [f1] is your original field.

 

The same concept can be achieved with the RegEx tool.

 - John

 

Alteryx Certified Partner
Alteryx Certified Partner
I agree with John. If the matching data is always numeric that you are discarding, you could change this to:

\d+-(.*)-\d+

ACE & Alteryx Certified Partner
Chaos reigns within. Repent, reflect and reboot. Order shall return.
rev
Meteor

Thanks John for your solution! I plugged it in and it worked.

Have a great day!

rev
Meteor

Thanks @MarqueeCrew for your input. There might be cases where there's more than just digits on either side of the "-" delimiter. Thanks!