Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.

Alteryx Designer Desktop Discussions

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

Separate a string that has multiple delimiters by middle delimiter only

bleu
8 - Asteroid

Hi,

 

Anyone know of a fast way to separate this:

 

Input

123-Apple-ABC-123-Apple-DEF
123-Grapes-QRS-123-Apple-XYZ
123-Pears-ABC-123-Grapes-TUV

 

Desired Output:

123-Apple-ABC123-Apple-DEF
123-Grapes-QRS123-Apple-XYZ
123-Pears-ABC123-Grapes-TUV

 

 

In the input there are no spaces.

If there is a similar post can someone provide a link?

 

Thanks!

7 REPLIES 7
ArtApa
Alteryx
Alteryx

@bleu - Here is a possible solution:

ArtApa_0-1677714368529.png

 

flying008
15 - Aurora

Hi, @bleu 

 

As your want, after the 3rd '-' must be a number ? or the second 123 must be like the first 123?

 

flying008_0-1677720877869.png

 

 

^([\w\-]+?)-(\d.+?)$

 

bleu
8 - Asteroid

Thank you ArtApa, never used the Tile before

bleu
8 - Asteroid

flying008 I'd like it to work for any number or string or character at any length. There will always be a total of 5 "-"s in the string

I want it to always separate it by the third "-"

 

So I'd like it to work for something like this too:

 

Input

123W-ABC-67-123W-RTP-55
112W-ABC-4G-456W-QRS-55
789W-ABC-2-123W-LPN-22R

 

Output

123W-ABC-67123W-RTP-55
112W-ABC-4G456W-QRS-55
789W-ABC-2123W-LPN-22R
ShankerV
17 - Castor

Hi @bleu 

 

Below, I outlined the steps you can follow to build your own solution workflow.

 

Why should you try to build it yourself?

 

[1. It reduces professional risk] You might be tempted to copy a provided solution workflow. If you implement it without learning and understanding proper use, you risk it failing and being unable to fix it.

 

[2. You will increase personal proficiency] If you invest in understanding the concepts and build the solution yourself, you will be able to build workflow solutions better and more efficiently in the future.  

 

Build your own solution guide

1. Input your data with Column you want to split

2. Use the Regex tool.

(\w+\-\w+\-\w+)\-(\w+\-\w+)

Output method: Parse 

 

We encourage you to try it yourself. Refer to the below section only if you are stuck

 

Spoiler
ShankerV_0-1677759462567.png

 

Kudos to you! If you were able to build the solution yourself :)

 

Please share with us if you were able to successfully build it or if you are facing any issues.

 

Happy to help :)

 

You can learn more about how to use Regex tools to build your own solution with the help of 

https://regex101.com/

 

Many thanks

Shanker V

flying008
15 - Aurora

Hi, @bleu 

 

As you said, so the below regex expression for you:

 

^(\w+\-\w+\-\w+?)\-([\w-]+?)$

 

flying008_0-1677803892157.png

 

bleu
8 - Asteroid

Thank you flying008!

It's tricky but I'm starting to get the hang of it.

Labels