WebDesign Tips

Regular Expression Search

While working on a site that came from a different CMS than TYPO3 is discovered to my horror that just about every line of code had a class associated with it that served no purpose at all at times. So how on earth am I going to delete all those darn classes that had the same letters but different numbers after the letters and looked like this

 

class="whs33" or class="whs3"

 


  • Copy the html code into Dreamweaver
  • Use find and replace in Dreamweaver and make sure the 'regular expression box' is checked.
  • Highlight the class code and selected find and replace
  • Now change the code in the find line to this:

    class="whs[0-90]{1} or class="whs[0-90]{2}

     [0-9] means that numbers have to be replaced
     {1} means that single digits (example: 3) are involved
     {2} means that double digits (example: 33) are involved

  • Now select replace all  by leaving the replace code box empty so that the classes are all removed
  • Find and replace has to be run twice, once for single digit classes and another time for the double digit classes