Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

ReReplace all html tags except selected

Guest
Mar 27, 2008 Mar 27, 2008
Folks,
I'm trying to figure out how to eliminate all html tags in a string except for <img> and <a> tags. Any ideas? I've been stumped for several days.
thanks,
/r
319
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Deleted User
Mar 28, 2008 Mar 28, 2008
Answer from the Regex Advise Forums at this link: http://regexadvice.com/forums/AddPost.aspx?PostID=40752

======================
In it's simplest form I would suggest that might be:

<(?!(?:a|img)\s|/a>)[^>]*>

if CF doesn't like (?:):

<(?!(a|img)\s|/a>)[^>]*>
Translate
LEGEND ,
Mar 27, 2008 Mar 27, 2008
try this:

rereplace(str, "<[^(\/?(a |img )][^>]*>", "", "ALL")

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Mar 28, 2008 Mar 28, 2008
Hi Azadi. Thanks for the idea, but it doesn't seem to work.

None of the html tags get removed now.

Any other ideas?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Mar 28, 2008 Mar 28, 2008
LATEST
Answer from the Regex Advise Forums at this link: http://regexadvice.com/forums/AddPost.aspx?PostID=40752

======================
In it's simplest form I would suggest that might be:

<(?!(?:a|img)\s|/a>)[^>]*>

if CF doesn't like (?:):

<(?!(a|img)\s|/a>)[^>]*>
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources