sacad
(saad)
January 18, 2022, 12:48am
1
Hi All.
i have a text like this:
FirstName LastName 1234567:$45.77 01/07/21-31/07/21.
Example1: Adam Smith 1906039:$45.77 01/07/21-31/07/21.
Example2: Adam Smith 1906039: $45.77 01/11/21-31/11/21.
I would like to return Adam Smith, as well as 1906039(which is client ID and changes) as well as the amount of 45.77.
How would i do that in regex?
Yoichi
(Yoichi)
January 18, 2022, 1:05am
2
Hi,
Can you try the following?
m = System.Text.RegularExpressions.Regex.Match(yourString,"^(?<FIRSTNAME>\w+)\s+(?<LASTNAME>\w+)\s+(?<CLIENTID>\d+)[^\$]+\$(?<AMOUNT>[.,\d]+)")
Then
m.Groups("FIRSTNAME").Value
m.Groups("LASTNAME").Value
m.Groups("CLIENTID").Value
m.Groups("AMOUNT").Value
Note : m is Match type
Regards,
Yoichi
(Yoichi)
January 18, 2022, 1:16am
4
Hi,
If you need to extract from multiple lines, the following helps you.
mc = System.Text.RegularExpressions.Regex.Matches(yourString,"^(?<FIRSTNAME>\w+)\s+(?<LASTNAME>\w+)\s+(?<CLIENTID>\d+)[^\$]+\$(?<AMOUNT>[.,\d]+)",System.Text.RegularExpressions.RegexOptions.Multiline)
Sample20220118-2.zip (2.6 KB)
Regards,
system
(system)
Closed
January 21, 2022, 1:16am
5
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.