The Cache: Technology Expert's Forum
 
*
Welcome, Guest. Please login or register. November 21, 2008, 04:42:17 PM

Login with username, password and session length


Pages: 1 [2]
  Print  
Author Topic: heeeeeeeeeeeeelp  (Read 1559 times)
Bompa
Administrator
Expert
*****
Offline Offline

Posts: 208


View Profile WWW
« Reply #15 on: June 30, 2007, 03:25:48 PM »

I would like to do some experimenting, but since I am a css idiot, maybe you
could give me a sample of a page or a url to any page where this should work?


later,
Bompa
Logged

Bompa
Administrator
Expert
*****
Offline Offline

Posts: 208


View Profile WWW
« Reply #16 on: June 30, 2007, 03:48:15 PM »

nice one bompa.
it still doesnt work though?

/([^.#][a-zA-Z0-9_].*[\s]*{[^}])/m

so if we expand it into constituent parts we have

Match a string that follows these rules:
- Starts NOT with a . or #
- Immediately followed by any number of letters or numbers or underscores
- Then match any amount of whitespace
- Then it needs to find an open parenthesis
- It then matches until it hits a closing parenthesis, at which point it stops
-
* Works over multiple lines

I cannot see how this matches ALL classes within my stylesheet?
The critical part, the NOT . or # reads fine to me? What am i missing?

Cheers

I think you're verbalizing it wrong, but anyways, 

perk's code  /([^#\.][A-Za-z0-9_]+[\s]*{[^}]+)/m
your code   /([^.#][a-zA-Z0-9_].*[\s]*{[^}])/m

perk has the + sign, you don't, instead you have .*
he also has a + near the end.


still if i had a sample of text to parse i could experiment

Bompa
Logged

Bompa
Administrator
Expert
*****
Offline Offline

Posts: 208


View Profile WWW
« Reply #17 on: June 30, 2007, 06:08:10 PM »

Ok, you all must be sleeping like babies.

I dug up a sample of css.


This perl works for me:

while( $text =~ /(^[^#.]\w+\{.*?\})/msg ) { print "$1\n"; }

This says
The character immediately after a newline can not be a # nor .
Then followed by one or more alphanumeric characters
Then followed by a left curly brace
Then followed by anything, (including a new line)
Stop matching at the first right curly brace


While the above worked for me, it's likely that I do not have a complete sample of
the text you'll be parsing.  Let me know.


There seems to be a lot of confusion with the ^ and $ metacharacters, as well as with the /m and /s flags.


« Last Edit: June 30, 2007, 06:21:03 PM by Bompa » Logged

m0nkeymafia
Expert
****
Offline Offline

Posts: 236


Check it!


View Profile
« Reply #18 on: July 01, 2007, 08:20:09 AM »

Hey Bompa
Cheers for goin out your way matey!
I think i was sleeping / making up time with my gf lol

I managed to get a working version, some limitations, but works fairly well.
Not had much chance to test it though, i got it working on my sample set then fucked it off lol
Too much regex makes m0nkey a dull boy Sad

/^\s*([\w,:]*)\s*{([^}]*)}/m

When I get chance I'll have a play with ur code see if it works better

Cheers tho dude, you posted like 3 times in a row for me Smiley
Logged

I am Tyler Durden
thedarkness
Global Moderator
Lifer
*****
Offline Offline

Posts: 580



View Profile
« Reply #19 on: July 01, 2007, 07:09:46 PM »

Yeah Bomps,

You're like a true humanitarian......  ROFLMAO

Cheers,
td
Logged

"I want to be the guy my dog thinks I am."
 - Unknown
m0nkeymafia
Expert
****
Offline Offline

Posts: 236


Check it!


View Profile
« Reply #20 on: July 02, 2007, 12:52:16 AM »

hahahaha
well were not curing world hunger, but a thankya was needed to y'all
Logged

I am Tyler Durden
perkiset
Olde World Hacker
Administrator
Lifer
*****
Online Online

Posts: 5142


:sniffle: Humor was so much easier before.


View Profile
« Reply #21 on: July 02, 2007, 06:40:01 PM »

Hey all - sorry about not responding, turns out that even though I was mobile I was just to frigging happy being offline to make much use of my new broadband card to hook up.

Bomps - here is a bit of production CSS to look at (take from a bunch of different places in my code, this wouldn't necessary all be on one page, but gives a nice idea of what it all looks like:

Code:
<style>
<style type="text/css">
.arial { font-family: "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif; line-height: 120%; }
.normal { font-weight: normal; }
.bold { font-weight: bold; }
.wt { color: #FFFFFF; }
.pad { padding: 1px 5px 1px 5px; }
A.wt { text-decoration: none; }
A.wt:HOVER { background-color: #671218; }
.bk { color: #220004; }
A.bk { text-decoration: none; }
A.bk:HOVER { background-color: #c78289; color: #ffffff; }
.s9 { font-size: 9px; }
.s10 { font-size: 10px; }
.s11 { font-size: 11px; }
.s12 { font-size: 12px; }
.s14 { font-size: 14px; }
.s16 { font-size: 16px; }
.s18 { font-size: 18px; }
.s20 { font-size: 20px; }
.s24 { font-size:24px; }
.left { text-align: left; }
.center { text-align: center; }
.right { text-align: right; }

body {
margin: 0px 0px 0px 0px;
background-image: url('/graphics/bgtile.gif');
background-repeat: repeat;
}

#main {
padding: 10px 10px 10px 10px;
}
.placard {
background-color: #ffffff;
border-style: solid;
border-color: #000000;
border-width: 1px 3px 3px 1px;
padding: 5px 10px 20px 10px;
}

#clientArea {
padding: 0px 30px 40px 40px;
}

</style>

</style>

I am pretty consistent about my spacing, but there is no really strong standard out there for spacing / line breaking - I just write it so that it looks right.

These examples are all valid:

Code:
A.bk:HOVER { background-color: #c78289; color: #ffffff; }

A.bk:HOVER {
background-color: #c78289; color: #ffffff; }

A.bk:HOVER
{
background-color: #c78289;
color: #ffffff;
}
A.bk:HOVER{background-color:#c78289;color:#ffffff;}

I think your example of
/(^[^#.]\w+\{.*?\})/msg

is really close: I'd add that there *may* be white space between the class name and the first squiggly brace, but that's about it I think.

/p
Logged

If I can't be Mr. Root then I don't want to play.
m0nkeymafia
Expert
****
Offline Offline

Posts: 236


Check it!


View Profile
« Reply #22 on: July 03, 2007, 11:31:04 AM »

yeah perk i think ur right dude

mobile? where are ya?
Logged

I am Tyler Durden
perkiset
Olde World Hacker
Administrator
Lifer
*****
Online Online

Posts: 5142


:sniffle: Humor was so much easier before.


View Profile
« Reply #23 on: July 03, 2007, 12:17:54 PM »

Back now - I was at Lake Mead for the last 4 days - just bought a Sprint broadband (EVDO) card - it rocked. I was on the net and working for both the 4 hour drive up and back... but while I was there I just relaxed. Ahhh. Smiley

But now back to reality...  Wink ... it's accounting day so I am still officially MIA although available here and there.

/p
Logged

If I can't be Mr. Root then I don't want to play.
m0nkeymafia
Expert
****
Offline Offline

Posts: 236


Check it!


View Profile
« Reply #24 on: July 04, 2007, 12:40:31 PM »

accounting day? ouch
in britain the company u works for takes care of that Smiley
Logged

I am Tyler Durden
perkiset
Olde World Hacker
Administrator
Lifer
*****
Online Online

Posts: 5142


:sniffle: Humor was so much easier before.


View Profile
« Reply #25 on: July 04, 2007, 01:03:22 PM »

 ROFLMAO

I haven't worked for someone else since my teens. Employment sucks, but so does accounting  Wink

To each his own I guess...

/p
Logged

If I can't be Mr. Root then I don't want to play.
Pages: 1 [2]
  Print  
 
Jump to:  

Perkiset's Place Home   Best of The Cache   phpMyIDE: MySQL Stored Procedures, Functions & Triggers
Politics @ Perkiset's   Pinkhat's Perspective   
cache
mart
coder
programmers
ajax
php
javascript
Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks


Valid XHTML 1.0! Valid CSS!