HighDots Forums  

Re: regular expression

Javascript JavaScript language (comp.lang.javascript)


Discuss Re: regular expression in the Javascript forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
lallous
 
Posts: n/a

Default Re: regular expression - 08-06-2003 , 01:48 AM






Hello,

you cannot use other than characters class in the: [], you can only put
inside them something like:
[a-z] or [aeiyo] or [a-zA-z0-9] etc...

hope this script helps:

<script language="JavaScript">
<!--
s = "Hallo <b>Welt</b>; Wie geht's?";
match = s.match(/<([^>]+)>.*?<\/\1>/i);
if (match)
alert('there is a tag');
else
alert('there is no tag!');
//-->
</script>

Regards,
Elias
"rognox" <rognox (AT) yahoo (DOT) de> wrote

Quote:
Hallo,

i have this Code in javascript:

//------------------------
starttag="<b>";
endtag="</b>";

str="Hier steht <b>ein Text, der Testzwecken</b> dient";

chosentext="Testzwecken";

pattern=starttag+'.*?[^'+endtag+']'+chosentext;
//hier Fehler??

t=str.search(pattern);

if (t!=-1){
alert("Offenes Starttag vor chosentext");
}else{
alert("KEIN offenes Starttag vor chosentext");
}
//------------------------

I want to find out, if there is a open start-htmltag in front of my
chosentext.
I think, the regular expression is wrong?
Hope somebody can help my.

Thank you.



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.