"Noah Sussman" <bl******@gmail.comwrote in message
news:11**********************@p15g2000hsd.googlegr oups.com...
On Mar 28, 11:07 am, "Noah Sussman" <blink...@gmail.comwrote:
>var myMatch = myString.replace('blah', '');
of course I meant
var myMatch = myString.replace(/blah/g, '');
Thanks, though it doesn't quite work for what I want...
var myString = "the road to blah is long"
var myMatch = myString.replace(/blah/g, '');
alert(myMatch);
myString = "the road to there is long"
var myMatch = myString.replace(/blah/g, '');
alert(myMatch);
// which is a match?
....but you got me thinking down a new line. In Perl you can set a var =
!regexp to flip the match. So, I can iterate an array of matches and in
the loop look for :
// 'myArray' holds the target strings
// myRe holds the regexp
for (1=0;i<myArray.length;i=i+1) {
if (!re.test(myArray[i]) { //
//do stuff
or for a fixed string just...
// 'myArray' holds the target strings
for (1=0;i<myArray.length;i=i+1) {
if (myArray[i] !== 'blah') { //
//do stuff
My mistake was to try and construct a 'negative' test rather than look
for the failure of a positive one.
Thanks for the nudge!
Mark