Using RegEx to remove a word & numbers at the end of a string
- 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 there,
So I have a set of data with "CONG ###" at the end of each string. I was trying to use RegEx to remove those instances but I'm having trouble coming up with the right combination to remove it. It will always be the last 7 characters of the string. I've tried:
<\CONG (which only got rid of the word, but nothing after it)
<\CONG* (which only got rid of the word, but nothing after it)
<\CONG*\> (which only got rid of the word, but nothing after it)
<\CONG*$ (which didn't work at all)
\<\CONG+\ (which only got rid of the word, but nothing after it)
And <\CONG+\> (which only got rid of the word, but nothing after it)
Would someone be able to help me out?
Thanks!
Solved! Go to Solution.
- Labels:
- Regex
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hi Daniel,
That didn't work unfortunately. That didn't remove the CONG or the numbers after it.
**EDIT: apologies, there was user error there, I was using [ ] instead of { }. This does solve my problem.
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
@dmpope Awesome. Glad it worked. FYI - Not sure if you use sites like this but for me the best way to test Regex is with something like https://regexr.com/ or https://rubular.com/
Just dont paste sensitive data in there... 😀
