Strip out CSS

?

=?ISO-8859-1?B?u1Gr?=

In <
M said:
I need something that works IN REVERSE. i.e. I enter text, highlight
the expression I want removed, then it tells me the regular expression
needed to achieve that.

There's nothing that can work like that and be of any use. E.g., if
you have removed the string

class="foo"

then the simplest regex that would match it is just

class="foo"

I'm afraid the only way to make regular expressions that will match
more than just the target at hand, you'll have to build them yourself.
 
C

Chris F.A. Johnson

I thank all for some of your suggestions but most of them deal with CSS and
not the bigger issue of scripts, ads, irrelevant sidebars (tables or divs),
etc. Maybe I'm coming at this the wrong way.

As I mentioned, Notetab's script language does most stuff for me. In order
to strip out CSS though I need to strip out phrases like:
id="something"
class="something"
style="bunch of css attributes"

I've been playing around with Notetab's (v4.95) regular expression search
and replace but I can't seem to find a combination that finds the above
expressions.

Is there a regular expression program that will break this down for me? For
example, the program RegEx Coach lets you enter your text, then test various
regular expressions. The results are highlighted in real time in the text
you entered.

I have no idea how standard notepad's regular expression syntax is,
but this would match embedded style in *nix utilities:

style="[^"]*"

For example, with sed, this will remove all so long as there are no
quotes within the style themselves:

sed 's/style="[^"]*"//' index.html > newindex.html
I need something that works IN REVERSE. i.e. I enter text, highlight the
expression I want removed, then it tells me the regular expression needed to
achieve that.

Anything like that out there?

No. If you wanted to match the 12345 in abc12345def, the regex
could be any of:

abc\(123[0-9]5*\)def
abc\(1234[0-9]*\)def
abc\([0-9]*\)def
[a-z][a-z][a-z]\([0-9]*\)[a-z][a-z][a-z]
[a-z]bc\([0-9]*\)de[a-z]

... and an infinite number of other expressions.
 
D

dorayme

"M said:
dorayme said:
I did this (via the View | Page Style | No style) but FF still saves with
the CSS intact. When you open the saved page, there is all the CSS again. Am
I doing this wrong?

I did it via the developer tools menu, perhaps that was the
difference.
 
N

Neredbojias

Well bust mah britches and call me cheeky, on Fri, 20 Jul 2007 16:19:51
GMT M scribed:
I thank all for some of your suggestions but most of them deal with
CSS and not the bigger issue of scripts, ads, irrelevant sidebars
(tables or divs), etc. Maybe I'm coming at this the wrong way.

As I mentioned, Notetab's script language does most stuff for me. In
order to strip out CSS though I need to strip out phrases like:
id="something"
class="something"
style="bunch of css attributes"

I've been playing around with Notetab's (v4.95) regular expression
search and replace but I can't seem to find a combination that finds
the above expressions.

Is there a regular expression program that will break this down for
me? For example, the program RegEx Coach lets you enter your text,
then test various regular expressions. The results are highlighted in
real time in the text you entered.

I need something that works IN REVERSE. i.e. I enter text, highlight
the expression I want removed, then it tells me the regular expression
needed to achieve that.

Anything like that out there?

(PS, yes, I know that removing either the stylesheet or the embedded
styles will render any id and class calls irrelevant. However, there
are times when I need them intact, so it would be nice to have the
option. . .)

Why not change "<style="text/css">" and </style> to opening and closing
comment delimiters, respectively, then just reverse "class" and "id" for
all inline styles? Of course, the html itself (and j/s) would have to be
devoid of "id" calls.
 
N

Neredbojias

Well bust mah britches and call me cheeky, on Fri, 20 Jul 2007 20:09:17
GMT Chris F.A. Johnson scribed:
I thank all for some of your suggestions but most of them deal with
CSS and not the bigger issue of scripts, ads, irrelevant sidebars
(tables or divs), etc. Maybe I'm coming at this the wrong way.

As I mentioned, Notetab's script language does most stuff for me. In
order to strip out CSS though I need to strip out phrases like:
id="something"
class="something"
style="bunch of css attributes"

I've been playing around with Notetab's (v4.95) regular expression
search and replace but I can't seem to find a combination that finds
the above expressions.

Is there a regular expression program that will break this down for
me? For example, the program RegEx Coach lets you enter your text,
then test various regular expressions. The results are highlighted in
real time in the text you entered.

I have no idea how standard notepad's regular expression syntax is,
but this would match embedded style in *nix utilities:

style="[^"]*"

That would have been my suggestion but I don't think Notetab's regexes work
the same way.
 
M

M

Why not change "<style="text/css">" and </style> to opening and closing
comment delimiters, respectively,

That's an idea. . .
then just reverse "class" and "id" for
all inline styles? Of course, the html itself (and j/s) would have to be
devoid of "id" calls.

Sorry, not getting what you mean here.

M
 
N

Neredbojias

Well bust mah britches and call me cheeky, on Fri, 20 Jul 2007 22:11:59
GMT M scribed:
That's an idea. . .


Sorry, not getting what you mean here.

Well, it is a, er, "stretching" (half-baked) idea, but if you use regexes
to change "class" to "id" and vice-versa, there'll be no css with those
(renamed) names and...

Yeah. It sounded good before.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top