Get values separately with regular expression

E. 212 Number series Mobile Country Code (MCC) Mobile Network Code (MNC)
530 01

Output:
530

01

thanks
shaik

Hi @shaik.muktharvalli1

You can try this way, variable type is string

System.Text.RegularExpressions.Regex.Match("Inputstring","(\d+)\s(\d+)").Groups(1).Value

Output = 530

System.Text.RegularExpressions.Regex.Match("Inputstring","(\d+)\s(\d+)").Groups(2).Value

Output = 01

image

Regards,
Gowtham Krishnan

1 Like

Hi @shaik.muktharvalli1

Can you try the below

Match = System.Text.RegularExpressions.Regex.Match(Input,"(\d+\s+\d+)").Value
Output1 = Match.Split(" "c)(0)
Output2 = Match.Split(" "c)(1)

The image shows the output panel of a software interface indicating the start and immediate end of "BlankProcess23" execution, alongside some informational and status icons. (Captioned by AI)

Regards,

1 Like

I’ll give you yet another option using named groups:

Regex.Match("530 01", "(?<MCC>\d{3})\s(?<MNC>\d{2})", RegexOptions.ExplicitCapture)

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