How to extract name text from group of string with spaces using regular expression

For eg of we have text like
\n 154765 Om Sairam\n Student Information

Need to extract name (Om Sairam)from that complete text using regular expression
By using this,getting only name (Om).Need to get sai ram also.
System.Text.RegularExpressions.Regex.Match(variablename,“(?<=\d{6}\s)(\S+)”).ToString

can anyone please help?

grafik
as the . is not including the line break you can try for this compact pattern
grafik

HI @vnsatyasunil

System.Text.RegularExpressions.Regex.Match(variablename,“(?<=\d{6}\s)(\S.+)(?=\\n)”).ToString

Regards
Gokul

System.Text.RegularExpressions.Regex.Match(variablename,“(?<=\d{6}\s)(\S.+)”).ToString

Regards
Gokul

for example,we have2 students information.
For 1st student by using this
System.Text.RegularExpressions.Regex.Match(variablename,“(?<=\d{6}\s)(\S.+)”).ToString
we are getting desired value as Om Sairam.For 2nd student name how can we achieve?

123456 Om Sairam\n Student Information\n \n 1239587 Nama Shivaya\n Student Information\n

Hi @vnsatyasunil

How about this expression?

System.Text.RegularExpressions.Regex.Matches(yourString,"(?<=\d{6}\s)(\S.+)")(0)

image

Check out the XAML file

RegexMatches.xaml (6.0 KB)

Regards
Gokul

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