Code Comments
Programming Forum and web based access to our favorite programming groups."Xah Lee" <xah@xahlee.org> writes: > A|B, where A and B can be arbitrary REs, creates a regular expression > that will match either A or B. An arbitrary number of REs can be > separated by the "|" in this way. This can be used inside groups (see > below) as well. As the target string is scanned, REs separated by "|" > are tried from left to right. When one pattern completely matches, that > branch is accepted. This means that once A matches, B will not be > tested further, even if it would produce a longer overall match. In > other words, the "|" operator is never greedy. To match a literal "|", > use \|, or enclose it inside a character class, as in [|]. > > --end quote-- > > Note: In other words, the "|" operator is never greedy. > > Note the need to inject the high-brow jargon "greedy"here as a > latch on sentence. What is so hard to understand ? Should be perfectly clear even to a first year undergraduate. As for "greedy" even a minimal exposure to Djikstra's shortest path algorithm would have made the concept intuitive. And from memory, that is the sort of thing done in Computing 101 and in Data Structures and Algorithms 101 It seems to me that you want the Python doc to be written for morons. And that is not a valid complaint.
Post Follow-up to this messagevermicule <rambam@bigpond.net.au> writes: > "Xah Lee" <xah@xahlee.org> writes: [...] > > It seems to me that you want the Python doc to be written for morons. Not for morons, but for trolls. Don't feed them. -- Måns Rullgård mru@inprovide.com
Post Follow-up to this messagevermicule wrote: > > What is so hard to understand ? > Should be perfectly clear even to a first year undergraduate. > > As for "greedy" even a minimal exposure to Djikstra's shortest path > algorithm would have made the concept intuitive. And from memory, > that is the sort of thing done in Computing 101 and in Data Structures > and Algorithms 101 > > It seems to me that you want the Python doc to be written for morons. > And that is not a valid complaint. He's right actually. If we understand the term "greedy" as it's used in graph search and optimization algorithms, Python's RE matching actually IS greedy.
Post Follow-up to this messagealex goldman <hello@spamm.er> writes: > vermicule wrote: > > > He's right actually. If we understand the term "greedy" as it's used in > graph search and optimization algorithms, Python's RE matching actually IS > greedy. No, you're justabout the optimization metric. In regexes, "greedy" match optimizes for the longest match, not the fastest. And this is common regex terminology - man perlre and you will find discussion of "greedy" vs. "stingy" matching. -SEan
Post Follow-up to this messageSean Burke wrote: > > alex goldman <hello@spamm.er> writes: > > > No, you're justabout the optimization metric. > In regexes, "greedy" match optimizes for the longest match, > not the fastest. > > And this is common regex terminology - man perlre and you will > find discussion of "greedy" vs. "stingy" matching. Read what you quoted again. Everyone (Xah, vermicule, myself) was talking about "greedy" as it's used in graph search and optimization algorithms.
Post Follow-up to this messageOn Tue, 10 May 2005 04:58:48 -0700, alex goldman wrote: > Sean Burke wrote: ... > > Read what you quoted again. Everyone (Xah, vermicule, myself) was talking > about "greedy" as it's used in graph search and optimization algorithms. However the original quote was in the context of regular expressions, so discussion of the terminology used in regular expressions is far more relevant than the terminology used in graph search and optimisation algorithms. Lawrence
Post Follow-up to this messageLawrence Kirby wrote: > On Tue, 10 May 2005 04:58:48 -0700, alex goldman wrote: > > > ... > > > However the original quote was in the context of regular expressions, so > discussion of the terminology used in regular expressions is far more > relevant than the terminology used in graph search and optimisation > algorithms. I replied to "And from memory, that is the sort of thing done in Computing 101 and in Data Structures and Algorithms 101", and I fully explained what I meant by "greedy" as well. There was no ambiguity.
Post Follow-up to this messageOn Tue, 10 May 2005 06:52:18 -0700, alex goldman wrote: > Lawrence Kirby wrote: ... > > I replied to "And from memory, that is the sort of thing done in Computing > 101 and in Data Structures and Algorithms 101", and I fully explained wha t > I meant by "greedy" as well. There was no ambiguity. My response talks about relevance, not ambiguity. Lawrence
Post Follow-up to this messageLawrence Kirby wrote: > On Tue, 10 May 2005 06:52:18 -0700, alex goldman wrote: > > > ... > > > My response talks about relevance, not ambiguity. Well, your response was irrelevant.
Post Follow-up to this messagealex goldman <hello@spamm.er> writes: > Lawrence Kirby wrote: [snip] > > Well, your response was irrelevant. This entire discussion is irrelevant to most, if not all, of the newsgroups to which it's being posted. comp.lang.c, where I'm reading this, is for discussion of the C programming language; I see nothing about C. -- Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst> San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst> We must do something. This is something. Therefore, we must do this.
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.