RegEx for flexible 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
Hello everyone,
I've just started learning RegEx tool recently, and I'm having difficulty in finding the expression for the input data in example below:
value amount(S) 12.000 USD dsgho
value amount(S) 14.050.476,2364 USD grkjsfeetuee
abc zyx ghk value amount(S) 499 13.478.400.000 USD gheiurh
The problem is need to parse the number in front of "USD", which means 12.000 , 14.050.476,2364 , 13.478.400.000 (not "499"), and the numbers contain both "." and ",", hence I can't find a full expression for this.
So far I've only come up with this:
.*\(\w+\)\s which will be regular for the string part until the "(S)".
Please let me know if you have any idea for this expression.
Thank you very much,
Trinh
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
Thank you, but there is one more issue is that in the 3rd row:
abc zyx ghk value amount(S) 499 13.478.400.000 USD gheiurh
I only want to parse the 13.478.400.000, not the number "499", do you have any solution for this?
Thanks much
Trinh
- 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
Hello @daophuongtrinh,
How about this?
(.*\s)(.*)(\sUSD.*)
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
You can use the following expression: ([^\s]+)\sUSD.+$
Hope this answers your question, can I ask you to mark it as the solution? this will help other users to find it and mark the thread as solved. Many thanks!
Best,
Diego
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hi David, afv2688 and Diego,
Thank you very much, the expression of David and Diego worked out very well, but for some reason afv2688's expressions didn't work out.
Please find my full input data here, since it's in foreign language so let me explain more about these data to you:
- I need to parse the number in front of "VND" and the word "VND", the output should be like in the excel file attached. The first two rows have structure: [string(S)] [the number I need] VND [string]. But other rows contain this structure: [string(S)] [other number] [the number I need] VND [string]
- Besides, the number I need contains "." and sometimes contain "," as well, for example it can be 12.000.000 or 12.000.000,1234
So the proper expression is .*\s(.+\sVND).* or ([^\s]+\sVND).+$
Thank you very much for your kind support.
Best regards
Trinh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hi @daophuongtrinh ,
Would you be able to share your full dataset as your yxzp package isn't working.
Best,
Fernando V.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hi @fmvizcaino
Please find the input data and the yxmd with proper expression for this case in attachment.
Best regards
Trinh
