Is there a function in jQuery or JavaScript that does the same as strstr()
in PHP?
I have an AJAX response that should be 1,2,3,12,13,23 or 123. I want to check if 1 exists, then if 2 exists then if 3 exists.
Is there a function in jQuery or JavaScript that does the same as strstr()
in PHP?
I have an AJAX response that should be 1,2,3,12,13,23 or 123. I want to check if 1 exists, then if 2 exists then if 3 exists.
Ok I just found something that works!
http://my-sliit.blogspot.com/2008/06/search-string-javascript-like-strstr-in.html
Thanks for your contributions :)
Here is an implementation without any library/method calls:
Read about these javascript functions - indexOF() and lastIndexOf().
Try using this:
(From http://phpjs.org/functions/strstr:551)
Overall phpjs is pretty phenomenal.
Well, not built in.
String.indexOf( String str )
returns the integer index of the substring but then, you can easily build one: http://aimtb.wordpress.com/2011/03/16/strstr-in-javascript/