Reputation: 698
I am trying to match 'MyGroup' from the following string:
CN=MyGroup,OU=SomeOU,OU=AnotherOu,DC=SomeDC,DC=AnotherDC,DC=GB
Using the following Regex:
(?<=CN=).*?(?=,OU=)
This captures "MyGroup" however using an online regex tester I get matches() false. I need to get matches() true for this. I don't have access to the java code, just that it's validating against matches() true.
Upvotes: 1
Views: 43
Reputation: 626794
You can use
CN=([^,]+),OU=.*
See the regex demo.
Details
CN=
- CN=
string([^,]+)
- Capturing group 1: one or more non-commas,OU=
- a ,OU=
string.*
- any zero or more chars other than line break chars as many as possible.Upvotes: 1