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

ind a substring inner a string

P: n/a
den
in a variable I can to have more strings
some time this type
/b/c/d/zz/aaa/copy.gif

other this
/b/c/d/e/f/g/h/xxx/j/cas.gif

I would like to control if in the string there is this substring:
/h/xxx/;

what is the better (fast) solution?
Feb 19 '07 #1
Share this Question
Share on Google+
1 Reply

P: n/a
ASM
den a écrit :
in a variable I can to have more strings
some time this type
/b/c/d/zz/aaa/copy.gif

other this
/b/c/d/e/f/g/h/xxx/j/cas.gif

I would like to control if in the string there is this substring:
/h/xxx/;

what is the better (fast) solution?
str = '/b/c/d/e/f/g/h/xxx/j/cas.gif';

alert(str.indexOf('/h/xxx/')>=0); // true/false

if(str.indexOf('/h/xxx/')>=0) location = str;
else alert('error in string');

--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
Feb 19 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.