
March 17th, 2005, 04:56 PM
|
|
Contributing User
|
|
Join Date: Dec 2004
Posts: 50
Time spent in forums: 7 h 33 m 2 sec
Reputation Power: 9
|
|
Using regular expressions is the simplest way to find if something is after something else.
I found this good tutorial on how to do regular expressions in javascript at http://www.webreference.com/
You should have something like the code below, I have not tested the code.
Code:
var X = " This is a test, SHP - 3x3x3x3x3x3x"
var tmp = x.match(/\w.*SHP(\w.*)/);
if(regex.$1 = null) {
//nothing after SHP
}
else {
//something after SHP
}
Everything inside ( ) gets assigned to regex.$1 . If you have more then one set of ( ) in x.match each additional one becomes regex.$1, regex.$2, regex.$3 etc in the order they got declared
the \w says look for any word characters. These include letters, numbers, spaces, and punctuation.
Take a look at the URL I provided. It'll give you good information
|