Alteryx Designer Desktop Discussions

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

Removing an A with regex

brad_j_crep
8 - Asteroid

Hi, I have an address where in various spot the instead of an address I get something like 'A' or 'AAAAA.'  I've tried using a regex_replace(address, (A*), "")  but it ends up getting right of every 'A.'  What I'd like is for it to leave the field blank if there are only 'A' s in it.  Is there a way to remove the 'A's?

 

Thank you,

Brad 

6 REPLIES 6
MarqueeCrew
20 - Arcturus
20 - Arcturus

Try this ....

 

regex_match([Text],"a{1,}?")

 

Cheers,

Mark

Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
brad_j_crep
8 - Asteroid

Awesome!  Thanks!  New to the regex thing.  Making my way.

Can you explain the "a{1,}?" part?  I understand a is the letter I'm looking for and {1,} would be starting at the beginning and going to whenever?  what does the '?' do?

 

Thanks!

 

BRad

MarqueeCrew
20 - Arcturus
20 - Arcturus

a{1,} is looking for 1 or more a's

? is looking for 0, 1 or more occurrences of the preceding argument.

 

i tried the combination and got lucky on my first try :)

 

Cheers,

Mark

Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
Ned
Alteryx Alumni (Retired)

For completeness sake:.

 

? is 0 or 1 of something.  "a?bc" will match "abc" and "bc" but not "aabc".  Same as a{0,1}bc

+ is 1 or more of something. "a+bc" will match "abc" and "aabc" but not "bc".  Same as a{0,1}bc

* is 0 or more of something.  "a*bc" will match "abc" and "aabc" and "bc".  Same as a{0,}bc

Try http://regexr.com/ for testing out regular expressions - its really helpful.

brad_j_crep
8 - Asteroid

Wow!  The RegExr is awesome.  It's really helping with my data prepping!  Thanks for the tip!

 

Brad

MarqueeCrew
20 - Arcturus
20 - Arcturus
Glaaaaaaaaaaaad to lend aaaaaaaaaaa haaaaaaand.
Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
Labels