GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   Regular Expression Help (https://gfy.com/showthread.php?t=552681)

nibbi 12-15-2005 03:01 PM

Regular Expression Help
 
I need to remove style content code from within <td> tags on hundreds of html pages. I figure the easiest way to do this would be a regular expression and a text editor.

So, anyone here know how to write a regular expression to turn this...

<td height="15" class="xl24" style="height:11.25pt">

Into this...

<td>

Thanks

Lycanthrope 12-15-2005 03:08 PM

Maybe this can help you: http://www.htmlworkshop.com/srhtml98.html

com 12-15-2005 03:08 PM

Quote:

Originally Posted by nibbi
I need to remove style content code from within <td> tags on hundreds of html pages. I figure the easiest way to do this would be a regular expression and a text editor.

So, anyone here know how to write a regular expression to turn this...

<td height="15" class="xl24" style="height:11.25pt">

Into this...

<td>
Thanks



simple the hardest bit is you may have to debug some of my escaping...

in VI:

%s/\<td height\=\"15\" class\=\"xl24\" style\=\"height:11.25pt\"\>/\<td\>/g

com 12-15-2005 03:09 PM

you may or may not need to escape the colon and period... plus some of the <> may not need to be escaped although doing so shouldnt hurt the expression. hope this helps, im running out the door to LA or id test it for ya! ciao!

Dynamix 12-15-2005 03:11 PM

Is it just <TD> tags? If so I can write something real quick to do it for you

nibbi 12-15-2005 03:13 PM

Quote:

Originally Posted by com

in VI:

%s/\<td height\=\"15\" class\=\"xl24\" style\=\"height:11.25pt\"\>/\<td\>/g


Actually, the contents of the tags contain many, many different variations... so that won't work. I need to be able to clear out *anything* that is within the tag.

nibbi 12-15-2005 03:15 PM

Quote:

Originally Posted by Dynamix
Is it just <TD> tags? If so I can write something real quick to do it for you

Yes, just <td> tags. Thank you.

com 12-15-2005 03:16 PM

shit well last tidbit before I leave, the character $ means "end of", do a little reading on your regexes will show you how to do delete from <td -through end of line or statement and close it off with a >.

%s means match the following string
%s/shit/fuck/g means replace all instances of shit with fuck. ^ is beginning of doc or line $ is end. good luck wish i had more time! ciao

nibbi 12-15-2005 03:26 PM

Got something to work:

Search for this:
<td[^>]*>

Replace with this:
<td>

This was done in TextPad.

Dynamix 12-15-2005 03:37 PM

http://www.pimpts.com/dl/tdslicer.exe

Drag and drop files from Windows Explorer onto this. File is saved as the original but appended with _new..

ie:
original - c:\file.html
new - c:\file_new.html

Only parses .html and .htm files

nibbi 12-15-2005 04:05 PM

Quote:

Originally Posted by Dynamix

Cool tool, Thanks.

I used it on a few of the files and it worked perfectly. I used TextPad for the rest. Seemed to do the job faster.

Thanks again for helping me with this.


All times are GMT -7. The time now is 06:37 PM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123