Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Regex 101 Exercise I6 - Remove font directives from HTML
Remove all <font…> or </font> directives from an HTML string.
Comments
Anonymous
January 30, 2006
I'd run three regexes, myself...
<font> # get rid of font tags with nothing after the "t" in font
<font(s|r|n).?> # get rid of font tags with stuff after the "t" in font
</font> # get rid of closing font tags
But I suppose this would do equally well for most data:
</?font.?>Anonymous
January 30, 2006
</?font[^>]*>
With singleline and ignorecase options set will do the trick.Anonymous
January 31, 2006
I'd like to propose an exercise...
Given plaintext containing URLs, make the URLs clickable by adding <a> tags around them.Anonymous
February 01, 2006
Pattern:
b(w+://[-w._%d/#]+)b
Replace:
<a href="$1">$1</a>
Kind of loose, but do you really want to check for well-formed URLs with this too?Anonymous
February 01, 2006
Oops, missed ?, =, and #
Correct pattern:
b(w+://[-w._%d/#?=]+)bAnonymous
February 02, 2006
Semicolons and @ signs, too.
Watch out for URLs that end in a W-class character... those won't have a b on the end.
Bonus points for auto-detecting punctuation on the end and not including it (for example: http://example.com.)
Note both the period and the ) at the end of that last paragraph are not part of the URL.Anonymous
February 02, 2006
The comment has been removedAnonymous
June 09, 2009
PingBack from http://greenteafatburner.info/story.php?id=2278Anonymous
June 13, 2009
PingBack from http://quickdietsite.info/story.php?id=3999Anonymous
June 17, 2009
PingBack from http://pooltoysite.info/story.php?id=3274