Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Designer Desktop Discussions

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

Replace/Delete multiple parts of a string in formula

wenjuanchen
8 - Asteroid

Hello everyone,

 

I have a column of strings looking like this:

 

<p> This is the text. </p>

 

Is it possible for me to get rid of "<p>" and "</p>" using one formula? Can I use Regex?

 

Thank you so much for your help.

6 REPLIES 6
Bahouth12
7 - Meteor

Hello wenjuanchen,

 

One possible way to take out <p> and </p> and keep the text in between them using formula tool is like this:

 

 

Spoiler
REGEX_Replace([YourField], '(\s<.*?>)|(<.*?>\s)','')

 

 

Surendar28
5 - Atom

Hello Wenjuanchen,

 

 

You can use XML parse

 

Thanks

Surendar

 

tom_montpool
12 - Quasar

You can 'nest' formula functions:

 

Replace(Replace([YourField],"<p> ","")," </p>","")

 

wenjuanchen
8 - Asteroid

Thank you @Bahouth12 @Surendar28 @tom_montpool. There are three solutions!

Bozhena
5 - Atom

Hi Everyone,

 

I'm trying to replace multiple words in one string if the length of the string is more than for example 29. I used If and Replace formula but I can get up to 2 replace formulas under if function. Any suggestions are appreciated! 

 

The goal is to short address lines to the number for characters that can fit into the form line.

 

Thank You!

Bozhena 

tom_montpool
12 - Quasar

In this case I might be tempted to do things differently because maintaining nested ifs and nested replaces can get really confusing and tedious.

 

I would probably use a filter tool to split my address field into those that are longer than my maximum and those that are fine.

Then I'd create a table with the strings I want to find and what I want to replace them with. I'd then use those two streams of data to feed into the Find Replace tool.

Follow that with a Union to merge the unprocessed Filter stream with the Find Replace stream and you should be good to go.

Labels