Sign in to follow this  
Followers 0
zackrspv

[SOLVED] Regular Expression Help

3 posts in this topic

#1 ·  Posted (edited)

Let's say i have this code:

$sHTML = '<TABLE id=_ctl0_NavBar cellSpacing=0 cellPadding=0 width="100%">'
$sHTML = $shtml & '<TBODY>'&@CRLF
$sHTML = $shtml & '<TR>'&@CRLF
$sHTML = $shtml & '<TD width=3><IMG style="HEIGHT: 1px" alt="" src="D:\Documents and Settings\Administrator\Desktop\btc\images/spacer.gif" border=0></TD>'&@CRLF
$sHTML = $shtml & '<TD class=NavBar_TabOn noWrap align=middle width=120 height=22><A class=navbar_links href="D:\Documents and Settings\Administrator\Desktop\btc\default.aspx">Browse</A></TD>'&@CRLF
$sHTML = $shtml & '<TD width=1><IMG style="HEIGHT: 1px" alt="" src="D:\Documents and Settings\Administrator\Desktop\btc\images/spacer.gif" border=0></TD>'&@CRLF
$sHTML = $shtml & '<TD class=NavBar_TabOff noWrap align=middle width=120 height=22><A class=navbar_links href="D:\Documents and Settings\Administrator\Desktop\btc\search.aspx">Search</A></TD>'&@CRLF
$sHTML = $shtml & '<TD width=1><IMG style="HEIGHT: 1px" alt="" src="D:\Documents and Settings\Administrator\Desktop\btc\images/spacer.gif" border=0></TD>'&@CRLF
$sHTML = $shtml & '<TD class=NavBar_TabOff noWrap align=middle width=120 height=22><A class=navbar_links href="D:\Documents and Settings\Administrator\Desktop\btc\logout.aspx">Logout</A></TD>'&@CRLF
$sHTML = $shtml & '<TD width=1><IMG style="HEIGHT: 1px" alt="" src="D:\Documents and Settings\Administrator\Desktop\btc\images/spacer.gif" border=0></TD>'&@CRLF
$sHTML = $shtml & '<TD class=NavBar_TabOff noWrap align=middle width=120 height=22><A class=navbar_links href="D:\Documents and Settings\Administrator\Desktop\btc\admin/login.aspx">Admin</A></TD>'&@CRLF
$sHTML = $shtml & '<TD width="90%"><IMG style="HEIGHT: 1px" alt="" src="D:\Documents and Settings\Administrator\Desktop\btc\images/spacer.gif" border=0></TD></TR>'&@CRLF
$sHTML = $shtml & '<TR>'&@CRLF
$sHTML = $shtml & '<TD bgColor=#7898b5 height=1></TD>'&@CRLF
$sHTML = $shtml & '<TD bgColor=#ffffff height=1></TD>'&@CRLF
$sHTML = $shtml & '<TD bgColor=#7898b5 height=1></TD>'&@CRLF
$sHTML = $shtml & '<TD bgColor=#7898b5 height=1></TD>'&@CRLF
$sHTML = $shtml & '<TD bgColor=#7898b5 height=1></TD>'&@CRLF
$sHTML = $shtml & '<TD bgColor=#7898b5 height=1></TD>'&@CRLF
$sHTML = $shtml & '<TD bgColor=#7898b5 height=1></TD>' &@CRLF
$sHTML = $shtml & '<TD bgColor=#7898b5 height=1></TD>'&@CRLF
$sHTML = $shtml & '<TD bgColor=#7898b5 height=1></TD></TR></TBODY></TABLE>'&@CRLF
$sHTML = $shtml & 'asdf'

;- /////////////////// REGEX TO REPLACE THE ENTIRE TABLE /////////////////////////
$text = StringRegExpReplace($sHTML, '<TABLE id=_ctl0_NavBar(.*?)></TABLE>', " ")
;- ////////////////END REGEX TO REPLACE THE ENTIRE TABLE /////////////////////////

MsgBox(0, "title", $text)

I for the life of me, cannot figure out how to actually get it to remove the entire table. I don't know for sure if it's CRLF's or LF's or just CR's, they are just there as an example.

How can i accomplish that?

Edited by zackrspv

-_-------__--_-_-____---_-_--_-__-__-_ ^^€ñ†®øÞÿ ë×阮§ wï†høµ† ƒë@®, wï†høµ† †ïmë, @ñd wï†høµ† @ †ïmïdï†ÿ ƒø® !ïƒë. €×阮 ñø†, bµ† ïñ§†ë@d wï†hïñ, ñ@ÿ, †h®øµghøµ† †hë 맧ëñ§ë øƒ !ïƒë.

Share this post


Link to post
Share on other sites



$text = StringRegExpReplace($sHTML, '(?i)\<TABLE id=_ctl0_NavBar[\D\d]+\<\/TABLE>', "")


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

$text = StringRegExpReplace($sHTML, '(?i)\<TABLE id=_ctl0_NavBar[\D\d]+\<\/TABLE>', "")

sweet,

While trying to figure it out:

$text = StringRegExpReplace($sHTML, '<TABLE id=_ctl0_NavBar(.*?)>(?s)(.*?)(?s)</TABLE>', " ")

also seems to work. :)


-_-------__--_-_-____---_-_--_-__-__-_ ^^€ñ†®øÞÿ ë×阮§ wï†høµ† ƒë@®, wï†høµ† †ïmë, @ñd wï†høµ† @ †ïmïdï†ÿ ƒø® !ïƒë. €×阮 ñø†, bµ† ïñ§†ë@d wï†hïñ, ñ@ÿ, †h®øµghøµ† †hë 맧ëñ§ë øƒ !ïƒë.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0