Forum Moderators: open

Message Too Old, No Replies

stripping link tags only

"Object doesn't support this property or method"

         

codebreaker

12:10 am on Aug 12, 2004 (gmt 0)

10+ Year Member



I don't know much about regex, but I'm trying to write a function that strips the link tags from a string. here's what I have:

function striplinks( oldString )
{
return oldString.replace(/<[(a)¦(/a)].*>/g, "");
}

But I'm getting the error I mentioned above. What I'm attempting to do is look for a less-than, then either an 'a' or a '/a', then anything, then a greater-than.

Any ideas? Thanks, code-breaker

codebreaker

7:00 pm on Aug 12, 2004 (gmt 0)

10+ Year Member



In case anyone is interested, here's the solution:

function striplinks(buff)
{
var regEx = /<a[^>]*>/gi;
buff = buff.replace(regEx,"")
return buff;
}

...this only strips the opening link, not the closing link (the </a>), but it does the job. -codebreaker