Regex for this string

abc aklsjdfh asjkdh s (12323)

i want to get two values from this
name - abc aklsjdfh asjkdh s
number - 12323

@Gaurav_Bahuguna

Try this.

To find letters - [a-zA-Z]+
To find Numbers - \d+

1 Like

Hi,

How about the following?

Name: System.Text.RegularExpressions.Regex.Match(strData,"[\w\s]*\w(?=\s*\()")

Number: System.Text.RegularExpressions.Regex.Match(strData,"(?<=\()\d+(?=\))")

Regards,

Name: System.Text.RegularExpressions.Regex.Match(Variable,"\w+\s")
Number: System.Text.RegularExpressions.Regex.Match(Variable,"\d+")

Thanks
@Gaurav_Bahuguna

Its just giving me the first word i want all words in name - abc aklsjdfh asjkdh s

@Gaurav_Bahuguna

I didn’t provided this.

Have you tried this ?

yes but its not giving me full name just the first word

@Gaurav_Bahuguna,

Name: ([a-zA-Z]| )+
Number: (?<=()(\d+)(?=))

Thanks!

@Gaurav_Bahuguna

Please check this and it’s working fine.

Its working for me

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