Regex fun

Once again jEdit saves me massive amounts of time. Knocked this up today to help Scruff with a bunch of nasty html – all the html attributes had been left unquoted, IE <table border=1 cellpadding=0 bgcolor=#ffffff> etc etc. With jEdit’s regex find and replace however this was all it took to clean up every variant of it:

find ([a-zA-Z0-9]+?)=([#a-zA-Z0-9]+?\>)([^\&\"]) replace with $1=”$2″$3

I’m blogging it because I’m well chuffed with myself for remembering enough of regex syntax to pull that off ;) It can probably be done more cleanly but it worked, so I’m happy!

Post to Twitter Tweet This Post

No related posts.

  • Trackbacks are closed
  • Comments (0)
  1. No comments yet.