having another short regex problem.
Basically I have a string like such:
cn=WSG-AP-LO-COMMON-SITE-APPS,ou=ZFD,ou=SVC,ou=IGH
I’m trying to get just the WSG-AP-LO-COMMON-SITE-APPS from that string.
I’m trying something like this:
preg_match('/[cn=.]+.*[^,.*]+$/', $info[0]['groupmembership'][0], $matches);
print_r($matches);
Which returns:
Array
(
[0] => cn=WSG-AP-LO-COMMON-SITE-APPS,ou=ZFD,ou=SVC,ou=IGH,ou=WM,ou=SWQ,o=HEALTH
)
As with any simply delimited string, this is most easily done by splitting on the delimiters: first commas, then on the
=:And if you really will only want the first part, you can shorten it with another
list():But if you really wish to do it with a regular expression, it should work as:
([^,]+)matches everything up to the next,followingcn=.