Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Convert PERL regex to Javascript - Help Required 1

Status
Not open for further replies.

1DMF

Programmer
Jan 18, 2005
8,795
GB
Hello,

Can someone plese help to convert the following regex substitution I use in PERL to work for JavaScript.

Code:
$desc =~ s/<[^>]*>//gis;

basically I want to be able to search a form field and change any HTML tags to blank!

how do I go about this?

I have this but it doesn't work
Code:
val.replace(/<[^>]*>/g, '');

Thanks 1DMF


"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
Hi Cory,


Are you sure here's what I got
Code:
val = document.addphrase.TITLE.value;
val.replace(/<[^>]*?>/gi, '');
if(document.addphrase.TITLE.value != val){
 document.addphrase.TITLE.value = val;
 msg = msg + "Tags '<*>' in Title - Removed!\n";
}
when i type
<this is a tag> kill it
nothing gets replaced and my messaged isn't displayed.

any ideas why

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
ok i'm a doughnut - i needed
Code:
val = val.replace(/<[^>]*?>/gi, '');

thanks cory :)

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
i'm sure:

Code:
    var re = /<[^>]*?>/gi;
    var v1 = document.forms['f'].elements['t'].value;
    var v2 = v1.replace( re, "" );
    var msg;
    if ( v2 != v1 ) {
        document.forms['f'].elements['t'].value = v2;
        msg += "Tags '<*>' in Title - Removed!\n";
    }



*cLFlaVA
----------------------------
[tt]mr. pibb + red vines = crazy delicious![/tt]

[URL unfurl="true"]http://www.coryarthus.com/[/url]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top