Click here to Skip to main content
15,867,453 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.
Posted
Updated 7-Dec-21 21:29pm

JavaScript
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
 
Share this answer
 
Comments
CPallini 13-Nov-15 3:33am    
Nice, my 5.
Krunal Rohit 13-Nov-15 3:53am    
Thanks mate ;-)

-KR
If you expect the OU values to change, then
1) locate the first OU in the string using indexOf
2) use subString to parse string from the location found in step 1 to the end of the string.
 
Share this answer
 
Comments
CPallini 13-Nov-15 3:33am    
Have my 5.
Abhinav S 13-Nov-15 3:57am    
Thank you.
Member 10714689 13-Nov-15 5:05am    
thanks a lot.it works for me.
Abhinav S 13-Nov-15 5:06am    
Sure. Mark as answered if it helped.
A regular expression[^] would do the job.
 
Share this answer
 
Comments
Abhinav S 13-Nov-15 3:16am    
Countered the down vote. Regex could do the trick.
CPallini 13-Nov-15 3:33am    
Thank you, you super-energized vote more than balanced the down one. :-)
I suspect the down vote comes from laziness.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900