Regex for keeping only word characters before any other character

Hey, I need the regex to keep only first word characters. For example “text-yes” -> “test” , or “test_yes” -> “test”.

Thanks!

1 Like

You can try something like
^[a-zA-Z]*

Yah like this in Regex
str_output = System.Text.RegularExpressions.Regex.Match(strinput.ToString,”.*(?=\W)”).ToString.Trim

Cheers @jadbenn

Hi,

Hope the following helps you.

System.Text.RegularExpressions.Regex.Match(strData,".*(?=[\W_])").Value

Regards,

1 Like

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