Hi,
I have several lines in a text file. I need to get the last word in the last sentence.
Last sentence reads as 12345.00 $ 345.00 $123.45 765432 123.00 $ 1265.45
I need to get $ 1265.45. how can I do this using Regular expressions.
Thanks a lot,
Hi @A_Learner
[\d.,]+\s*\$\s*([\d.,]+)\s*
mkankatala
(Mahesh Kankatala)
August 7, 2023, 2:36pm
3
Hi @A_Learner
Check the below regular expression to extract the required Output
System.Text.RegularExpressions.Regex.Matches(yourstringinput.ToString,“((\$\s+\d+\.\d+)$)”)
Hope it helps!!
rlgandu
(Rajyalakshmi Gandu)
August 7, 2023, 2:37pm
4
@A_Learner
System.Text.RegularExpression.Regex.Match(Input,"\$\s+\d+\.\d+(?=$)").Value
1 Like
vrdabberu
(Varunraj Dabberu)
August 7, 2023, 2:42pm
5
@A_Learner
System.Text.RegularExpressions.Regex.Matches(yourstringinput.ToString,"((\$\s+\d+.?\d+)$)")
Hope it helps!!
($\s+\d+.\d+)$ Try with this
anjankum
(Anjani Kapoor)
August 7, 2023, 3:04pm
7
Hi,
Please try this regex - [$\s]?(\d+.\d+)$
Thanks!
Anil_G
(Anil Gorthi)
August 7, 2023, 3:13pm
8
@A_Learner
Actuall you can get directly with split as well
Str.Split({"$"},StringSplitOptions.None).Last
Cheers
Hey @A_Learner ,
You can try this regex - \$\s*\d+\.?\d+$
Thank you, @Anil_G This works.
All other solutions are getting me multiple results as they are matching dollar amounts in the file multiple places. Thanks every one!
1 Like
system
(system)
Closed
August 10, 2023, 3:34pm
11
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.