I need to match certain parts of a string using regex and am having a terrible time trying to figure it out. The string in question will always look like this:
CN=Last.First.M.1234567890, OU=OrganizationalUnit, O=Organization, C=CountryName
The resulting string will look like CN=1234567890,
so I need to just get the first part of the string up to and including the ,
and strip out the Last.First.M.
part. Can this be done?
Note: I am passing this regex into a function which I cannot touch, so I cannot use easier methods such as splitting the string or getting just the digits and adding the CN=
to it.
Thanks.