John Machin wrote:
>> Your wording makes it hard to distinguish what exactly is "dopey".
>>
>
> """
> dopey implementations of search() (which apply match() at offsets 0, 1,
> 2, .).
> """
>
> The "dopiness" is that the ^ operator means that the pattern cannot
> possibly match starting at
John Machin wrote:
> The point was made in a context where the OP appeared to be reading a
> line at a time and parsing it, and re.compile(r'something').match()
> would do the job; re.compile(r'^something').search() will do the job too
> -- BECAUSE ^ means start of line anchor -- but somewhat r
John Machin wrote:
[...]
> Observation: factoring out the compile step makes the difference much
> more apparent.
>
> >>> ["%.3f" % t.timeit() for t in t3, t4, t5, t6]
> ['1.578', '1.175', '2.283', '1.174']
> >>> ["%.3f" % t.timeit() for t in t3, t4, t5, t6]
> ['1.582', '1.179', '2.284', '
Devan L wrote:
> John Machin wrote:
>
>>Devan L wrote:
>>
>>>John Machin wrote:
>>>
>>>
Aahz wrote:
>In article <[EMAIL PROTECTED]>,
>John Machin <[EMAIL PROTECTED]> wrote:
>
>
>
>>Search for r'^something' can never be better/faster than match for
>>r'som
John Machin wrote:
> Devan L wrote:
>
>> John Machin wrote:
>>
>>> Aahz wrote:
>>>
In article <[EMAIL PROTECTED]>,
John Machin <[EMAIL PROTECTED]> wrote:
> Search for r'^something' can never be better/faster than match for
> r'something', and with a dopey implementatio
John Machin wrote:
> Devan L wrote:
> > John Machin wrote:
> >
> >>Aahz wrote:
> >>
> >>>In article <[EMAIL PROTECTED]>,
> >>>John Machin <[EMAIL PROTECTED]> wrote:
> >>>
> >>>
> Search for r'^something' can never be better/faster than match for
> r'something', and with a dopey implementa
Devan L wrote:
> John Machin wrote:
>
>>Aahz wrote:
>>
>>>In article <[EMAIL PROTECTED]>,
>>>John Machin <[EMAIL PROTECTED]> wrote:
>>>
>>>
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
John Machin wrote:
> Aahz wrote:
> > In article <[EMAIL PROTECTED]>,
> > John Machin <[EMAIL PROTECTED]> wrote:
> >
> >>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 wor
Aahz wrote:
> In article <[EMAIL PROTECTED]>,
> John Machin <[EMAIL PROTECTED]> wrote:
>
>>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 newbi
Duncan Booth wrote:
> 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 wor
Jeff Schwab wrote:
> John Machin wrote:
>
>> 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'.
>
>
> H
In article <[EMAIL PROTECTED]>,
John Machin <[EMAIL PROTECTED]> wrote:
>
>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
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
>
John Machin wrote:
> 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'.
How else would you match the beginn
Duncan Booth wrote:
> Dan wrote:
>
>
>>>My (probably to naive) approach is: p = re.compile(r'\b#include\b)
>>
>>I think your problem is the \b at the beginning. \b matches a word break
>>(defined as \w\W or \W\w). There would only be a word break before the #
>>if the preceding character were a \
Tom Deco wrote:
> Hi,
>
> I'm trying to use a regular expression to match a string containing a #
> (basically i'm looking for #include ...)
>
> I don't seem to manage to write a regular expression that matches this.
>
> My (probably to naive) approach
Dan wrote:
>> My (probably to naive) approach is: p = re.compile(r'\b#include\b)
>
> I think your problem is the \b at the beginning. \b matches a word break
> (defined as \w\W or \W\w). There would only be a word break before the #
> if the preceding character were a \w (that is, [A-Za-z0-9_], a
Thanks,
That did the trick...
--
http://mail.python.org/mailman/listinfo/python-list
> My (probably to naive) approach is: p = re.compile(r'\b#include\b)
I think your problem is the \b at the beginning. \b matches a word break
(defined as \w\W or \W\w). There would only be a word break before the #
if the preceding character were a \w (that is, [A-Za-z0-9_], and maybe
some other c
Hi,
I'm trying to use a regular expression to match a string containing a #
(basically i'm looking for #include ...)
I don't seem to manage to write a regular expression that matches this.
My (probably to naive) approach is: p = re.compile(r'\b#include\b)
I also tried
20 matches
Mail list logo