Alteryx Designer Discussions

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

Replace Wildcard

ddye
8 - Asteroid

Hi,

 

Anyone see my mistake?  

 

I have records in Notes History field with this text: [03/28/2013 - 15:07, BY: Chris Juergens] that I am trying to remove from each row.

 

Have looked into using Replace and Wildcard, but not having any luck removing it.

 

Formula: Replace([Notes History],"[*]","")

 

Thank you.  

 

 

7 REPLIES 7
michael_treadwell
ACE Emeritus
ACE Emeritus

The regex wildcard is the '.' character. Also you need to escape your brackets with '\' since brackets represent regex operations.

 

Edit, forgot something else:

 

The REPLACE function searches for an identical string match. You are looking for the function REGEX_REPLACE

 

Try this:

 

REGEX_REPLACE([Notes History],"\[.*\]","")

ddye
8 - Asteroid

Thanks Michael, I will give it a shot.  I should have mentions that I was using formula, not RegEx.  I will try this in Regex though.  

michael_treadwell
ACE Emeritus
ACE Emeritus

You can still use Formula!

 

REGEX_REPLACE() is a function available in the formula tool.

ddye
8 - Asteroid

Ah, thanks.  I am obviously brand new to RegEx.  

 

That worked, but unfortunately I have multple sets of bracketed text in each row I am trying to remove: (this is all in one record/row)

 

[04/08/2016 - 16:14, BY: Jessica Reynolds]
Verified with Heather - ice machine is working

Resolution: Warranty
[03/22/2016 - 16:39, BY: Jessica Reynolds]
Speaking with Jason - Tech has been out - evaportor needs to be ordered.

 

This formula looks to be finding the first '[' and the last ']', so I am losing the struck-thru section in the middle that I would like to keep.  If there isn't a way to do it, it is not the end of the world.  I am having trouble understanding the regex formula, so I might be able to figure it out after I work through it and understand it.  

 

Thanks.   

michael_treadwell
ACE Emeritus
ACE Emeritus

Try to make it non-greedy by adding in a '?'

 

REGEX_REPLACE([Notes History],"\[.*?\]","")

 

Heads up that newlines can affect the algorithm as well if you have breaks inside of your text cell.

ddye
8 - Asteroid

Thank you so much Michael.  No I just have to figure out how it works 🙂 


@michael_treadwell wrote:

Try to make it non-greedy by adding in a '?'

 

REGEX_REPLACE([Notes History],"\[.*?\]","")

 

Heads up that newlines can affect the algorithm as well if you have breaks inside of your text cell.


 

ddye
8 - Asteroid

Will [\s\S] fix the the newline issue? 


@ddye wrote:

Thank you so much Michael.  No I just have to figure out how it works 🙂 


@michael_treadwell wrote:

Try to make it non-greedy by adding in a '?'

 

REGEX_REPLACE([Notes History],"\[.*?\]","")

 

Heads up that newlines can affect the algorithm as well if you have breaks inside of your text cell.


 


 

Labels