Regular expression to match an ldap connection string

zerokill

New Member
I need to extract information from an LDAP connection string like this one:\[code\]ldap://uid=adminuser,dc=example,c=com:[email protected]/dc=basePath,dc=example,c=com\[/code\]I want to use a regular expression that will extract each token for me and place it in an array. I tried some regex expression and the best I got was this:\[code\]/(\w+)\:\/\/(([a-zA-Z0-9]+)(:([^\:\@]+))?@)?([^\/]+)((\/[^#]*)?(#(.*))?)/\[/code\]But unfortunately, when I execute it in PHP, I get the following result:\[code\]Array( [0] => ldap://uid=adminuser,dc=example,c=com:[email protected]/dc=basePath,dc=example,c=com [1] => ldap [2] => [3] => [4] => [5] => [6] => uid=adminuser,dc=example,c=com:[email protected] [7] => /dc=basePath,dc=example,c=com [8] => /dc=basePath,dc=example,c=com)\[/code\]Can anybody help me so that I can correctly extract each part of the connection string?Thanks
 
Back
Top