simple RE?
Andrew Kuchling
akuchlin at mems-exchange.org
Mon May 14 10:29:14 EDT 2001
"BA" <asdffdsa at bellatlantic.net> writes:
> the concept is that i do not care if there is leading white space or not. i
> do care that the first non-white space character is NOT a single quote. i am
> pat_oe_ok1=r"^[^']\s*Option Explicit"
> pat_oe_ok2=r"^\s*[^']\s*Option Explicit"
Dissect these patterns:
^ # Match at start of string
[^'] # Match a single character that isn't "'"
\s* # Match zero or more whitespace characters
Option Explicit# Match this literal string.
It's not really clear to me exactly what you're trying to match
because I didn't understand your explanation. I don't see why the
simple pattern "^\s*Option Explicit" wouldn't be a suitable pattern;
you don't have to match strings like "print Option Explicit", do you?
BTW, see the Regular Expression HOWTO at
http://py-howto.sourceforge.net/regex/ ; it may explain regex patterns
in more detail than the book you're using.
--amk
More information about the Python-list
mailing list