By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,449 Members | 972 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,449 IT Pros & Developers. It's quick & easy.

Stripping string

sashi
Expert 100+
P: 1,754
Hi everyone,

I have a question, i need to find the occurrence of a particular symbol </> in a string. Lets say, i have a string in the following format <aaaaa/bb/cc/dddd>, i need to break this into 4 portions, how do i do that in JavaScript?

In the case above i need to look for first occurrence of the </> symbol in order to find the first portion and so on for next occurrence of the </> symbol to find the respective portion, right?

Hope someone can point me in the right direction, thanks in advance. Take care.
Dec 5 '06 #1
Share this Question
Share on Google+
4 Replies


P: 23
I'm not sure if you're looking for "/" or "</>" but you could try using split. Split return s an array.

Expand|Select|Wrap|Line Numbers
  1. var vString = "aaa/bb/c/ddd";
  2. var arrString = vString.split("/");
  3.  
  4. // arrString[0] = "aaa"
  5. // arrString[1] = "bb"
  6. // arrString[2] = "c"
  7. // arrString[3] = "ddd"
  8.  
Dec 5 '06 #2

sashi
Expert 100+
P: 1,754
I'm not sure if you're looking for "/" or "</>" but you could try using split. Split return s an array.

Expand|Select|Wrap|Line Numbers
  1. var vString = "aaa/bb/c/ddd";
  2. var arrString = vString.split("/");
  3.  
  4. // arrString[0] = "aaa"
  5. // arrString[1] = "bb"
  6. // arrString[2] = "c"
  7. // arrString[3] = "ddd"
  8.  
Hi there,

Thanks a million to you, i'll try it out right away. Take care.
Dec 5 '06 #3

P: 23
You're welcome :) I hope it works!
Dec 5 '06 #4

sashi
Expert 100+
P: 1,754
You're welcome :) I hope it works!
Hi there,

Just to let you know, the solution you provided worked fine, just the way in wanted. Thanks once again. Good luck & Take care.
Dec 6 '06 #5

Post your reply

Sign in to post your reply or Sign up for a free account.