Removing an A with regex
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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
Solved! Go to Solution.
- Labels:
- Preparation
- Regex
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Try this ....
regex_match([Text],"a{1,}?")
Cheers,
Mark
Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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
Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Wow! The RegExr is awesome. It's really helping with my data prepping! Thanks for the tip!
Brad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.