need to extract parts of a CN using regex, had to do a quick output, but not happy with the hard coding like "CN="
CN:
CN=LAW\\, JUDE,OU=VIDEO,OU=External,OU=Security - Administrator Accounts,DC=cool,DC=kats
REGEX:
CN=(?<lastname>\w+)\\\\, (?<firstname>\w+),OU=(?<ou>\w+)
RESULT:
Full match | 1-24 | `CN=LAW\\, JUDE,OU=VIDEO` |
Group `lastname` | 4-7 | `LAW` |
Group `firstname` | 11-15 | `JUDE` |
Group `ou` | 19-24 | `VIDEO` |