Regex to remove space at the end

I have this regex

^(\D*)

That I use to get the string before the number. For reference, here’s my sample text:

Company One 11.18.2021.pdf

I can get the “Company One” part, but it also include the space before the “11.18.2021”
I hope you can help me, thank you.

Hi,

How about the following expression?

System.Text.RegularExpressions.Regex.Match(yourString,"^\D*[^\d\s]").Value

Regards,

Thanks it worked!

1 Like

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