SOLVED
How to parse text from a string that contain special character, text and number
Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
minniiko
5 - Atom
‎09-09-2021
05:30 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hi everyone,
I'm trying to parse a set of data that has the Account Description in this format:
Car Parking Sales (Cash) (105)
Project Expense (External) (104.2)
Transportation - Others (Deployment) (444.95)
I want to parse it to separate the text details (including "-") from the number in parenthesis.
Could you please help?
Solved! Go to Solution.
Labels:
- Labels:
- Regex
3 REPLIES 3
cmcclellan
14 - Magnetar
‎09-09-2021
05:42 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
There might be a cleaner way, but this works ....
([a-zA-Z\ \(\)\-]*)(\d*\.*\d*)
ncrlelia
11 - Bolide
‎09-09-2021
06:08 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hi @minniiko,
My suggestion would be (.+)\s\((\d+.*\d+)\)
- (.+)
- .+ = the character before the numbers
- () helps to identify the value to parse (i.e. output)
- \s = the space between the text and numbers
- \((\d+.*\d+)\)
- \d+.*\d+ = numbers in the brackets, including "." if any
- () identify the value to parse
- () = to the original brackets for the numbers, added \ to escape the special characters. This is not include within () as we do not want it in the output.
Hope this helps.
Cheers,
Lelia
‎09-09-2021
06:12 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
This works like a charm!!! Thank you both so much! Cheers!
