community
cancel
Showing results for 
Search instead for 
Did you mean: 

Alteryx designer Discussions

Find answers, ask questions, and share expertise about Alteryx Designer.

Regex String

Meteor

Hi RegEx Experts!

 

I need to take a substring with the following rules

From the - not including it,  until the second / (but not including it)

 

So from this string below

qwert, qdsaw g s XYZ-UPO/ET/R/RD

 

the output would be  UPO/ET

Would also want a seperate field with the result   UPO/ET/R

 

Can you give me the two RegEx patterns please?

 

Thanks

 

Alteryx Certified Partner
Alteryx Certified Partner
Regex_replace([field],".*?-(\u+\/\u+)\/.*",'$1')

".*?-(\u+\/\u+\/\u+)\/.*"

Cheers

Mark
Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and reboot. Order shall return.
Quasar

Here you go

 

UPO/ET - use parse method output with regular expression  (\w{3}/\w{2})

UPO/ET/R- use parse method output with regular expression (\w{3}/\w{2}/\w)

 

 

Meteor

Sorry should have been more specific, the number of characters between / can vary

 

I need all characters up to but excluding the slashes.

Quasar

Here you go. 

 

UPO/ET - use parse method output with regular expression (\w+/\w+)

UPO/ET/R- use parse method output with regular expression (\w+/\w+/\w)

Alteryx Certified Partner
Alteryx Certified Partner

did you try my formulae?

Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and reboot. Order shall return.
Meteor

Yes worked for most fields but not all (like when there is not two / in the string).

 

I put a few more examples.  Appreciate the efforts as im a bit lost.

 

Input: qwert, qdsaw g s XYZ-UPO/ET/R/RD

Output 1 needed:    UPO/ET

Output 2 needed     UPO/ET/R

 

Input: qwert, qdsaw g s XYZ-UPO/ETRS/RTR

Output 1 needed:    UPO/ETRS

Output 2 needed:    UPO/ETRS/RTR 

 

Input: qwert, qdsaw g s XYZ-UPO/E

Output 1 needed:    UPO/E

Output 2 needed:    UPO/E

 

Input: qwert, qdsaw g s XYZ-UPO

Output 1 needed:    UPO

Output 2 needed:    UPO

 

Input: qwert, qdsaw g s XYZ-UPO/E

Output 1 needed:    UPO/E

Output 2 needed:    UPO/E

 

Input: qwert, qdsaw g s XYZ-UIOO/ERP/Q/F

Output 1 needed:    UIOO/ERP

Output 2 needed:    UIOO/ERP/Q

 

Quasar

Here is the sample workflow for your case.  Hope this is helpful. 

 

workflow.PNGWorkflowResults.PNGResultsResults2.PNGResults

Meteor

Thanks for the workflow, but I have a 500,000 records to apply this to, so this approach wouldnt be ideal.

 

Hoping for a formula/regex approach

Quasar

I just replaced one text to column tool with regex tool. Apart from that, I could not do much to simplify the workflow.  However, I am curious to know if the workflow I shared worked for your 500,000 records. 

 

workflow.PNGWorkflow

Labels