更新时间:2023-02-18 20:03:23
var str = ' LDAP:// XYZ_2010_dev1 / OU = sample,OU = test,DC = 2010dev1,DC = com',
delimiter = ' /',
start = 3 ,
tokens = str.split(delimiter).slice(start),
result = tokens.join(定界符);
提醒(结果);
这样做:)
-KR
如果您希望更改OU值,那么
1)使用indexOf
找到字符串中的第一个OU
2)使用subString
来解析从步骤1中找到的位置到字符串末尾的字符串。
正则表达式 [ ^ ]可以胜任。
Hi.
I have a string like:
"LDAP://XYZ_2010_dev1/OU=sample,OU=test,DC=2010dev1,DC=com"
Now I want the only this part from the string:
OU=sample,OU=test,DC=2010dev1,DC=com
How to get this using java script?
Thanks in Advance.
var str = 'LDAP://XYZ_2010_dev1/OU=sample,OU=test,DC=2010dev1,DC=com', delimiter = '/', start = 3, tokens = str.split(delimiter).slice(start), result = tokens.join(delimiter); alert(result);
This will do :)
-KR
If you expect the OU values to change, then
1) locate the first OU in the string usingindexOf
2) usesubString
to parse string from the location found in step 1 to the end of the string.
A regular expression[^] would do the job.