re.match

Michael P. Soulier msoulier at nortelnetworks.com
Tue Mar 20 16:19:51 EST 2001


On 20 Mar 2001 21:29:31 +0100, Martin von Loewis
>
>You have to take two things into account:
>
>a) you were critizing the author of the regex code (in its sre incarnation),
>and 

    While a certain paranoid interpretation of my question could certainly
result in an assumption of criticism, it was in fact a question. My statement
of, "that's what the ^ is for" was perhaps too general, but if you ask someone
what the ^ is for in a regexp, they'll probably tell you, "it means to match
only if the pattern appears at the beginning of the line", no? It is within
this general context that I made that statement, and I'm astonished at the
amazing lack of tolerance I've experience here (and with Usenet in general
really). For some reason people seem to think it's ok to be impolite when you
have a computer to hide behind. I'm sick of it. The very fact that I was not
given the benefit of the doubt is, I believe, a symptom of how badly people
often treat each other on Usenet.
    Thank you for your polite and informative response btw. I'll work harder
to keep myself from being misinterpreted in the future, but it's quite
difficult without one's tone of voice and body language included, and the
first instinct of so many Usenet denizens is to immediatly flame. Be original,
and try tolerance, I say. 

>b) this is regular expressions, which seem be unfriendly by nature (which
>perhaps had an influence on comp.lang.perl.misc as well :-) >

    Naw, I think they just inherited it from comp.lang.c ;-)

c) Fredrik spent
>quite some time getting all the "start of line" and "start of string" cases
>right. It was difficult to write, so it should be difficult to understand :-)

    Now there's an argument against code documentation if I've ever heard one.
;-)

>I find match extremely useful, and I never ever use search. The reason is
>that I use regular expressions for tokenization of languages with a formal
>syntax. There, I don't care whether the point where I look for the next token
>happens to be the start of a line - but I absolutely must make sure that any
>match I get is at the current position (or else there is a syntax error).

    I suppose what I expected was that the ^ in the pattern would enable the
optimization of the search that match provides. My experience with regular
expressions is completely with the Unix tools that use them (ie. grep, awk,
sed, vi...) and Perl. This is the first time I've encountered two different
methods of invoking a regexp comparison. If that's because I've never used the
C API for them, fine. 
    Apparently match also provides additional functionality that these tools
did not previously, to my knowledge, give me access to. 

>Please have a look at the undocumented sre.Scanner class for an example of
>using match in a loop.

    Thanks.

>> As always, one asks questions not to simply annoy, but to learn. There was
>> a time when Usenet was a good place to do that.
>
>Well, maybe you should phrase your question in a way that encourages
>discussion. You've stated 

    I thought I did. See above.

    As the road to hell was paved with good intentions, I suppose what I meant
to imply doesn't count for much, but it did not warrant the initial response,
or the followup that I have chosen to ignore. I do not permit anyone to speak
to me like that "gentleman" already has. I really could care less who they
are. 

    Thanks again,

    Mike

-- 
Michael P. Soulier, TD12, SKY  Tel: 613-765-4699 (ESN: 39-54699)
Optical Networks, Nortel Networks, SDE Pegasus
"With sufficient thrust, pigs fly just fine. However, this is not necessarily a
good idea. It is hard to be sure where they are going to land, and it could be
dangerous sitting under them as they fly overhead." -- RFC 1925
Nortel Linux User's Group Ottawa: (internal) http://nlug.ca.nortel.com



More information about the Python-list mailing list