RegExp Problem

M

Martin Nadoll

Hi,

i want tofind out, whether the string: <!-- Flash --> is found in my string.
i tried:
var iz='anything here, than <!-- Flash --> and than anything here';
cflash = iz.match(/-- Flash --/g);
if (cflash) {
alert('found');
}

but it is not found :-(

Thanks for any help on that,
Martin Nadoll
 
S

Stevo

Martin said:
Hi,

i want tofind out, whether the string: <!-- Flash --> is found in my string.
i tried:
var iz='anything here, than <!-- Flash --> and than anything here';

then, not than
cflash = iz.match(/-- Flash --/g);
if (cflash) {
alert('found');
}

but it is not found :-(

if(iz.indexOf("<!-- Flash -->")>-1){
alert('found');
}
 
T

Thomas 'PointedEars' Lahn

Martin said:
i want tofind out, whether the string: <!-- Flash --> is found in my string.
i tried:
var iz='anything here, than <!-- Flash --> and than anything here';
cflash = iz.match(/-- Flash --/g);
if (cflash) {
alert('found');
}

but it is not found :-(

You forgot to declare `cflash', and you should use /.../.test(iz) instead.
In any case, WFM in Firefox/Iceweasel 3.0.6 and Internet Explorer 6.0.
However, you might be running into a peculiarity of the used script engine
(which one?) that regards <!-- ... --> as multi-line comment. Displaying
the value of `iz' would clarify that.

If it is regarded as a comment, you should be able to work around that using
`<\!-- ... -->' and the like.

Please take heed of <http://jibbering.com/faq/#posting>.


HTH

PointedEars
 
S

SAM

Le 4/24/09 4:02 PM, Martin Nadoll a écrit :
Hi,

i want tofind out, whether the string: <!-- Flash --> is found in my string.
i tried:
var iz='anything here, than <!-- Flash --> and than anything here';
cflash = iz.match(/-- Flash --/g);
if (cflash) {
alert('found');
}

but it is not found :-(

Yes it is : the alert fires.



var iz='something here, then <!-- Flash --> and then something here';
cflash = iz.match(/-- Flash --/g);
if (cflash) {
alert('found');
iz = iz.replace (/-- Flash --/g, '-- --')
alert('next : '+
(iz.match(/-- Flash --/)?'found':'not found')+
'\niz = '+iz);
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,102
Messages
2,570,645
Members
47,245
Latest member
ShannonEat

Latest Threads

Top