regex - VB6 regular expression for whitespace remover in HTML -


i'm trying run regular expression [\s]+(<)|(>)[\s]+

dim myregexp object set myregexp = new regexp myregexp.multiline = true myregexp.ignorecase = true myregexp.global = true myregexp.pattern = "[\s]+(<)|(>)[\s]+" 'myregexp.test (str) str = myregexp.replace(str, "$2$1")  

this doesn't seem work

you can test run regular expression on http://www.regextester.com/ , work perfectly

it's suppose remove whitespace left , right of html tags optimize webpage without removing whitespace in actual text inbetween html tags.

<br>        adsfdf </br> <img     asdddasd      >   sdfdsf <br>           <yah>43 3453490 90                             <tag> <tag> 

turns into

<br>adsfdf</br><img asdddasd>sdfdsf<br><yah>43 3453490 90<tag><tag> 

why doesn't work in vb6/vbscript? thanks

try instead:

myregexp.pattern = "\s+(<)|(>)\s+" str = myregexp.replace(str, "$2$1") 

vb6/vbscript regexes don't \s in character class.


Comments

Popular posts from this blog

Add email recipient to all new Trac tickets -

400 Bad Request on Apache/PHP AddHandler wrapper -

php - Change action and image src url's with jQuery -