Python regex
Andrew Rekdal
Thu Mar 13 16:08:43 EDT 2008
made error on last line... read as...
> I would be saying if forward-slash AND asterisk appear in this order...
> negate
--
-- Andrew
"Andrew Rekdal @comcast.net>" <<nospam> wrote in message
news:qLKdnR6s8a4xFUTanZ2dnUVZ_qmlnZ2d at comcast.com...
>I hope posting is ok here for this question...
>
> I am attempting to extract the text from a CSS comment using 're' such
> as...
>
> string = "/* CSS comment /*"
> exp = "[^(/*)].*[^(*/)] "
>
> p = re.compile(exp)
> q = p.search(string)
> r = q.group()
>
> print r
>
>>>CSS comment
>
> although this works to a degree... I know the within the brackets
> everything is taken literally so the pattern
> I am to negating is "(/*)". ie. includes the parenthesis.
>
> So my question is...
>
> Is there a way to negate a pattern that is more than on character long?
> eg. where rather than saying if forward slash OR astrisk appear..negate.
>
> I would be saying if parenthesis AND asterisk appear in this order...
> negate
>
>
> -- Andrew
>
>
More information about the Python-list
mailing list