Reddy_1
(Berdy)
1
Hi all,

996 Charla Lane, Richardson, TX, United States
51, avenue Jules Ferry, 02200 SOISSONS, France
42 Great Western Road, LOOSEGATE, United Kingdom
I want Only Country from above values. How to extract it. I think Split method wont work. Can we use Regex if yes please help.
Regards,
Reddy.
Hi @Reddy_1 ,
You could try the split method (first split by new line, and afterwards split by comma) like this:
Demo file: SplitMethod.xaml (6.2 KB)
Hope this helps!
Best regards,
Marius
1 Like
prasath_S
(prasath S)
3
Hi @Reddy_1
try using this regex [\w ]*$

1 Like
Hi @prasath_S ,
Is this pattern working for countries like Guinea-Bissau or Timor-Leste?
Best regards,
Marius
prasath_S
(prasath S)
5
Hi @Marius_Puscasu
This will work [\w -]*$ and also we can add all the special characters we need.
Thanks
2 Likes
Yoichi
(Yoichi)
6
Hi,
If you want to use Split method, the following expression will work.
arrResult = yourString.Split(vbcrlf.ToCharArray,StringSplitOptions.RemoveEmptyEntries).Select(Function(s) s.Split(","c).Last.Trim).ToArray
if use regex, the following also works. (It will match characters except comma at the end of line.)
mc = System.Text.RegularExpressions.Regex.Matches(yourString,"[^\s,][^,]+(?=\r?\n|$)")
Main.xaml (8.6 KB)
Regards,
system
(system)
Closed
7
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.