Hi i need help to create a suitable regex extract only the data i want
example :
CityNorth California State/ProvinceSMT Postal Code2222 Country/Region America
i want to get the value only of/Output
California
SMT
2222
America
it will be nice if the output can be seperated with new line like above
that means it will ignore
City
State/Province
Postal Code
Country/Region
Thank you
Yoichi
(Yoichi)
April 21, 2022, 4:38am
2
Hi,
Can you try the following expression?
String.Join(vbCrLf,System.Text.RegularExpressions.Regex.Match(yourString,"City(.*)State/Province(.*)Postal Code(.*)Country/Region(.*)").Groups.Cast(Of System.Text.RegularExpressions.Group).Skip(1).Select(Function(m) m.Value.Trim))
Regards,
Yoichi:
String
it works like magic Yoichi ,
thank you
1 Like
Hi YOichi i have a question
it it posstoble to get something like this as an output
i want to get the value only of/Output
City California
State/Province SMT
Postal Code 2222
Country/Region America
or
City,California
State/Province,SMT
Postal Code,2222
Country/Region,America
thank you
Yoichi
(Yoichi)
April 21, 2022, 6:18am
5
Hi,
How about the following?
String.Join("",System.Text.RegularExpressions.Regex.Match(yourString,"(City)(.*)(State/Province)(.*)(Postal Code)(.*)(Country/Region)(.*)").Groups.Cast(Of System.Text.RegularExpressions.Group).Skip(1).Select(Function(m,i) m.Value.Trim+if(i mod 2 =0,",",vbcrLf)))
Regards,
1 Like
system
(system)
Closed
April 24, 2022, 6:19am
6
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.