How to get String within a String with Regex

Hello Community,

i have a problem with my regex expression. What i want is a Name within a String.

For Example, the following is the String:

25.03.2022 14:39:32, KK922GG - Bruce Willis (it is a normal name)

What i have marked in bold is the name i want to extract.

I am getting with this regex expression

KK922[a-zA-Z]+\s*-(\s([a-zA-Z]+\s)+)(it is a normal name)

a few results:
Match 1: KK922GG - Bruce Willis (it is a normal name)
Group 1: Bruce Willis
Group 2: Willis

Is there another solution (maybe easier) to get ONLY the Name Bruce Willis as (maybe) one Match?

Thank in advance for the help and answers

Best Regards


Can you try the following expression?

System.Text.RegularExpressions.Regex.Match(yourString,"(?<=-\s+).*?(?=\s+\(it is a normal name\))").Value



Great. Thank you!!

1 Like

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