Reputation: 183
I have an LDAP path similar to the one below, I want to extract the text between the first OU= and the comma that follows it, in the example below the text I need is "Support Group". Can anyone suggest a Regex to do this?
CN=James Regus,OU=Support Group,DC=Internal,DC=Com
Upvotes: 1
Views: 2967
Reputation: 70125
This regular expression will put the text between the OU=
and the next ,
into $1 or \1 or what have you depending on how the language handles such things.
/\bOU=(.*?),/
(This assumes your regular expression parser supports \b
as a shortcut for 0-length wordbreak matching.)
I don't know what programming language you're using, but let's say it's JavaScript. Here's some sample code:
var regex = /\bOU=(.*?),/;
var ldapPath = 'CN=James Regus,OU=Support Group,DC=Internal,DC=Com';
var match = ldapPath.match(regex);
alert(match[1]);
Upvotes: 2