Free Trial

Alteryx Designer Desktop Discussions

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

Split string using regex

kbsocgen
6 - Meteoroid

Hello,

 

I'm new to regex and would greatly appreciate some help with splitting below text string into two columns  - Short Name and Full Name. 

 

Input String

Third Party.... ASI LTD Asstton Sealuck I Limited
Third Party.... ASII LTD Asstton Sealuck II Limited
Third Party.... ASIV LTD Asstton Sealuck IV Limited
Third Party.... AZLAGOS AVERAGE ZONALTAG LAGOS
Third Party.... ABCD FOOTY ABCD FOOTIE Manchesta Industria
Third Party.... LALEASMARC LA Leassee (March) Limited

 

Expected result

Short NameFull Name
ASI LTDAsstton Sealuck I Limited
ASII LTDAsstton Sealuck II Limited
ASIV LTDAsstton Sealuck IV Limited
AZLAGOSAVERAGE ZONALTAG LAGOS
ABCD FOOTYABCD FOOTIE Manchesta Industria
LALEASMARCLA Leassee (March) Limited

 

 

Thank you

7 REPLIES 7
Qiu
21 - Polaris
21 - Polaris

@kbsocgen 
I really dont see a pattern here... 😁
Do you have any logic for the parsing?

flying008
15 - Aurora

Hi, @kbsocgen 

 

There is a so poor way for you .

 

1- Parse Expression:

 

 

^.+\.{4}\s([A-Z])([A-Z]+\s*[A-Z]+)(?=\s\1)\s(.*)$

 

 

 

2- Gif.

 

录制_2022_08_26_10_09_01_673.gif

 

@Qiu 

******

Dear, the [Short Name] is the abbreviation of company name, and the [Long Name] is the full name.

edittmer
5 - Atom

If there is a regex logic this site helps with dynamically showing you the effect of expressions: https://regexr.com/

kbsocgen
6 - Meteoroid

Hi @flying008 

 

I tested your parse expression but it only works on two records and not all (screenshot attached). Please can you check?

 

kbsocgen_0-1661497700953.png

 

Thanks

flying008
15 - Aurora

Hi, @kbsocgen 

 

The reason is that the data I use is the table data you posted above, and you are using the data in the Inputfile.txt file. The two data sources are different, because the number of spaces in the middle of the string is not the same, thus your result is different from my screenshot.

 

******

If input the data of inputfile.txt, you can try use below expression,  then fix the row-6 puzzle(move the 'LA' to full name) with formula tool.

 

 

 

 

^.+\.{4}\s([A-Z])([A-Z]+\s*[A-Z]+)(?=\s+\1)\s+(.*)$

 

 

 

If you get the desired result, please give me a solution, thanks!  😁

kbsocgen
6 - Meteoroid

Hi @flying008 - the expression works with the input file. Thank you

flying008
15 - Aurora

Hi, @kbsocgen 

 

Please mark this as the solution if it answers your question, it will help others to find solutions quicker.

Labels
Top Solution Authors