Closed Thread Icon

Topic awaiting preservation: Regular Expression help? (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=12701" title="Pages that link to Topic awaiting preservation: Regular Expression help? (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: Regular Expression help? <span class="small">(Page 1 of 1)</span>\

 
jdauie
Bipolar (III) Inmate

From: Missoula, MT
Insane since: Jan 2003

posted posted 04-26-2003 00:19

Salutations...

I would appreciate any help you could give me here. I am just learning regular expressions.

This is my regular expression:

([\w+\-?]*)(\s*:\s*[\S^\{]+\s*

$1 is supposed to be matching Cascading Style Sheet attributes and $2 is matching the attribute value.
It works fine except for 2 cases where it does not match...

1) If the CSS contains a line like the following, that has no space between an attribute and the semi-colon that precedes it.

.yellow {color:#000000;background-color:#ffff00;}

2) If there is a line like this, with a space anywhere within the attribute value.

font-family:Courier New,Lucida Console,serif;

[edit]I was able to fix problem #2 by changing the expression, but then it only recognized the first attribute on a line (in all cases).[/edit]

Thanks again for any help!

Josh Morey

[This message has been edited by jdauie (edited 04-26-2003).]

[This message has been edited by jdauie (edited 04-26-2003).]

[This message has been edited by jdauie (edited 04-26-2003).]

WarMage
Maniac (V) Mad Scientist

From: Rochester, New York, USA
Insane since: May 2000

posted posted 04-26-2003 17:17

Next time comment your regular expression if you are having trouble.

([^:]+) [^;]+);

That might be a way to do it.

What that one is doing is reading everything that is NOT a : and then requiring a : at the end. Then it is reading everything that is NOT a ; and then requiring a ; at the end.
You might need to tone the allowable characters down, but that is just grunt work.


Me

jdauie
Bipolar (III) Inmate

From: Missoula, MT
Insane since: Jan 2003

posted posted 04-27-2003 19:42

ok, thanks WarMage...

Like I said, I am new at this.

Maskkkk
Paranoid (IV) Inmate

From: Willaimsport, PA, US of A the hole in the Ozone
Insane since: Mar 2002

posted posted 05-03-2003 18:56

Anybody know a handy regular expression tool similar to the one that came with Komodo? (I used to use it, but they make you pay for Komodo now.)



- Face the Present
- AIM: MASKKKK

Tyberius Prime
Paranoid (IV) Mad Scientist with Finglongers

From: Germany
Insane since: Sep 2001

posted posted 05-03-2003 23:28

what is komodo, and why don't you build your own helpfull regexp tool?

Petskull
Maniac (V) Mad Scientist

From: 127 Halcyon Road, Marenia, Atlantis
Insane since: Aug 2000

posted posted 05-04-2003 19:39

why are you doing this... what, are you making a browser or something?

...and... um.... I'm with TP... what's Komodo?


Code - CGI - links - DHTML - Javascript - Perl - programming - Magic - http://www.twistedport.com
ICQ: 67751342

Piper
Paranoid (IV) Inmate

From: California
Insane since: Jun 2000

posted posted 05-04-2003 21:30

I'm pretty sure this is the Komodo that Maskkkk is talking about: http://www.activestate.com/Products/Komodo/

Komodo has a nifty little regex tool incorporated into the IDE. You can find info and a screenshoot about two-thirds of the way down on this page: http://www.activestate.com/Products/Komodo/more_information.plex

~Charlie

DmS
Paranoid (IV) Inmate

From: Sthlm, Sweden
Insane since: Oct 2000

posted posted 05-04-2003 23:06

The few times I absolutley have to use regexp I use this tool to test whatever I fumble together. http://www.quanetic.com/regex.php?nojs=1
/Dan

{cell 260}
-{ a vibration is a movement that doesn't know which way to go }-

« BackwardsOnwards »

Show Forum Drop Down Menu