Jesus 'n Jim

A mainly PC (some Mac) site w/Software, Computer Repair Info, How-To's on Using Computers
Technical Support 1-360-521-2060 (my business line cell)

regular expression (regexp) tricks

 

These are tricks you can do with Dreamweaver or your programmer's editor or possibly with an editor that supports Regular Expressions (regex). basically, it's some search-and-replace things you can do to save time with your html editing. your editor may require that the < and > be escaped with a \ character in front — check your manual. the TSE editor uses {} instead of (). Dreamweaver requires fixing before you can do anything with ^, $, or (), so if you want it fixed, submit a bug report. as a workaround you can replace using "specific tag" for many of these. Anyone got a good xhtml-->html or html-->xhtml converter?

URL to this document

<div>\s*<br>\s*<br>\s*<br>\s*<a\s+href="(.*)">(.*)</a>\s*&nbsp;&nbsp;&nbsp;&lt;———>URL to this document</div> replace with <div><br /><br /><br /><a href="$1" target="_blank" class="visitorext">$2</a>&nbsp;&nbsp;&nbsp;&lt;———>URL to this document</div>

convert most of xhtml to html

<(.*)/\s*> replace with <$1>

convert html to xhtml (partially), 11 replaces

<[Mm][Ee][Tt][Aa]\s*(.*)> to <meta $1 />
<[Ii][Nn][Pp][Uu][Tt]\s*(.*)> to <meta $1 />
<[Ii][Mm][Gg]\s*(.*)> to <img $1 />
<[Pp][Aa][Rr][Aa][Mm]\s*(.*)> to <param $1 />
<[Ff][Ii][Ee][Ll][Dd][Ss][Ee][Tt]\s*(.*)> to <fieldset $1 />
<[Hh][Rr]\s*(.*)> to <hr $1 />
<[Ff][Rr][Aa][Mm][Ee]\s*(.*)> to <frame $1 />
<[Cc][Oo][Ll]\s*(.*)> to <col $1 />
<[Cc][Oo][Ll][Gg][Rr][Oo][Uu][Pp]\s*(.*)> to <colgroup $1 />
<[Pp](\s*)(.*)> to <p$1$2>
</P> to </p>
<[Dd][Ii][Vv]\s*(.*)> to <div$1>
</[Dd][Ii][Vv]> to </div>
(\s)[Hh][Rr][Ee][Ff]=(['"]?)(\S*)(['"]?) replace with $1href="\3"
(\s)[Ss][Rr][Cc]=(['"]?)(\S*)(['"]?) replace with $1src="\3"

dl,dt,dd

replace </?dl> with nothing
replace <dt class="heading">(.*)</dt> with <div class="dtheading">$1</div>
replace <d([dt])>(.*)</d[td]> with <div class="d\1">$2</div>

dreameaver regex search for old singleton tags

Search for <input((?:\s+(?:[a-zA-Z]+="[^"]*?"|[a-zA-Z]+='[^']*?'|[a-zA-Z]+=[^'"][^>\s]*|[a-zA-Z]+))*\s*)> and replace with <input$1 /> but before making it global, make sure you do a find all and check on any questionable results or results where you can't see the whole answer in the results pane.

dreameaver regex search for open/close tags

Search for <a((?:\s+(?:[a-zA-Z]+="[^"]*?"|[a-zA-Z]+='[^']*?'|[a-zA-Z]+=[^'"][^>\s]*|[a-zA-Z]+))*\s*)>([^<]*?)</a> and replace with <a$1 class="visitorext" target="_blank">$2</a> or whatever you like, but before making it global, make sure you do a find all and check on any questionable results or results where you can't see the whole answer in the results pane. this is tricky. because of the total greediness of * and the total laziness of *?, having tags (such as an img) between an anchor tag can present a problem. it may match more than its share or it may not match at all. check your search results first.

summary

you may need to edit these. this is a basic framework idea from which to start.