Regular expression to match a #
duncan.booth at invalid.invalid
Thu Aug 11 17:46:40 CEST 2005
John Machin wrote:
>> Alternatively for C style #includes search for r'^\s*#\s*include\b'.
> Search for r'^something' can never be better/faster than match for
> r'something', and with a dopey implementation of search [which
> Python's re is NOT] it could be much worse. So please don't tell
> newbies to search for r'^something'.
Search for r'^something' is always better than searching for r'something'
when the spec requires the search to match only at the start of a line (on
the principle that code that works is better than code which doesn't).
It appears that this may be something the original poster wanted, so I
stand by my suggestion.
More information about the Python-list