We are celebrating the 10-year anniversary of the Alteryx Community! Learn more and join in on the fun here.
Start Free Trial

Alteryx Designer Desktop Discussions

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

Remove certain words from string field and keep the remaining

KGAYATH4
5 - Atom

Hello All, 

 

I need your help in using right tool to remove certain words from string field. Words are dynamic. Its a 5 letter words each followed by _. I need to remove 8th and 9th word from the string and keep the remaining. Need to remove red highlighted. Its always 8th and 9th word. But string might have more than 50 words as well. 

 

Example string - A1235_CA#VA_DG**U_DR--C_E19BJ_SE#FL_TR-A7_PN@@Z_13JVW_DJKAC

 

Thank you for the support. 

 

Regards,

Gayathri K

5 REPLIES 5
caltang
17 - Castor
17 - Castor

Like so?

 

image.png

Calvin Tang
Alteryx ACE
https://www.linkedin.com/in/calvintangkw/
gawa
16 - Nebula
16 - Nebula

hi @KGAYATH4 I propose 2 method.

First is static method by using REGEX like this. It's very simple, but if you need change the position to be removed, you need to rephrase REGEX. 

REGEX_Replace([Field1], "^([^_]{5}_[^_]{5}_[^_]{5}_[^_]{5}_[^_]{5}_[^_]{5}_[^_]{5}_)[^_]{5}_[^_]{5}_(.+)$", "$1$2")

Second is dynamic method by using Text to Column and Tile tool. You just have to specify the position of the words to be removed in Filter tool. It would be much easier to customize WF even if your input data/requirement change in future.

image.png

caltang
17 - Castor
17 - Castor

Haha! Nice @gawa san! Same thought process for the dynamic portion.

Calvin Tang
Alteryx ACE
https://www.linkedin.com/in/calvintangkw/
KGAYATH4
5 - Atom

Thank you so much. I will try this. 

flying008
15 - Aurora

Hi, @KGAYATH4 

 

Another dynamic solution of Regex for you,

Spoiler
REGEX_Replace([Txt], '^((?:[^_]{5}_){7})((?:[^_]{5}_){2})', '$1')
RegExTxt
InputA1235_CA#VA_DG**U_DR--C_E19BJ_SE#FL_TR-A7_PN@@Z_13JVW_DJKAC
OutputA1235_CA#VA_DG**U_DR--C_E19BJ_SE#FL_TR-A7_DJKAC

 

 

 

Labels
Top Solution Authors