Need to get correct output using REGEX or other things

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

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,

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

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

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.