Regex question
- 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 am still learning regex and I would kindly ask the community for help.
Can someone provide me with information on how wright regex that will remove | (vertical dash) as the last sign?
Usually I have more then one so it should remove one or more of them but only if vertically dash is the last character.
Input
ABC|||||
Expected output:
ABC
I also have
ABC|ABD||||
Expected output:
ABC|ABD
I hope that makes sense 🙂
Solved! Go to Solution.
- Labels:
- Regex
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hello @Emil_Kos ,
I'm no expert either bt you could try using this:
REGEX_Replace([Field1], '(.*\>)(\|+)', '$1')
This removes the pipelines at the end of the word.
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hi @afv2688,
Thank you for taking a look.
Something isn't working as expected.
It removed also | from the middle of the string and If that was the case he didn't remove them from the end of the string.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hello @Emil_Kos ,
You are telling me it's working the other way around? That's weird!
I mean I'm getting the results as expected, could you share some more examples to see what is going on with my tests?
Regards
- 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
Also, a less complicated solution:
REGEX_Replace([Field1], '\|\|+', '')
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hi @afv2688,
I actually currently use this formula 😀
The only problem with it is that if the last character is a dash and it is only one it will not remove it.
Currently I have another formula tool that is correcting this but I wanted to explore the topic and learn how to do it with one regex tool 😀
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hi @afv2688,
I think this mock data will better represent my data set
AB ds,adsaC|ABds a,dC.|||||||
ABC, ABC|ABC ABC ABC”|||||||
ABC, ABC|ABC ABC ABC”|
The output from the more complicated solution that you have provided:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hello @Emil_Kos
Ok then, not elegant at all:
REGEX_Replace(REGEX_Replace([Field1], '(.*\>)([\W*&^\|])(\|*)', '$1$2'),'(.*\>)(\|*)','$1')
but it became a personal challenge to get it XD
Regards
