1
我需要從一個LDAP連接字符串,像這樣的提取信息:正則表達式匹配的LDAP連接字符串
ldap://uid=adminuser,dc=example,c=com:[email protected]/dc=basePath,dc=example,c=com
我想用正則表達式來提取每個令牌對我來說,並放置在數組。我嘗試了一些正則表達式,我得到了最好的是這樣的:
/(\w+)\:\/\/(([a-zA-Z0-9]+)(:([^\:\@]+))[email protected])?([^\/]+)((\/[^#]*)?(#(.*))?)/
但不幸的是,當我在PHP執行它,我得到以下結果:
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
)
任何人可以幫助我,讓我可以正確提取連接字符串的每個部分?
感謝
哪種語言是您使用?你可以編輯你的問題來顯示你的樣本字符串的預期結果嗎?部件的順序和數量是否可變? – 2010-09-21 13:45:03