Re: + in regular expression

Discussion in 'Python' started by Cameron Simpson, Oct 6, 2012.

  1. On 05Oct2012 10:27, Evan Driscoll <> wrote:
    | I can understand that you can create a grammar that excludes it. [...]
    | Was it because such patterns often reveal a mistake?

    For myself, I would consider that sufficient reason.

    I've seen plenty of languages (C and shell, for example, though they
    are not alone or egrarious) where a compiler can emit a syntax complaint
    many lines from the actual coding mistake (in shell, an unclosed quote
    or control construct is a common examplei; Python has the same issue
    but mitigated by the indentation requirements which cut the occurence
    down a lot).

    Forbidding a common error by requiring a wordier workaround isn't
    unreasonable.

    | Because "\s{6}+"
    | has other meanings in different regex syntaxes and the designers didn't
    | want confusion?

    I think Python REs are supposed to be Perl compatible; ISTR an opening
    sentence to that effect...

    | Because it was simpler to parse that way? Because the
    | "hey you recognize regular expressions by converting it to a finite
    | automaton" story is a lie in most real-world regex implementations (in
    | part because they're not actually regular expressions) and repeated
    | quantifiers cause problems with the parsing techniques that actually get
    | used?

    There are certainly constructs that can cause an exponential amount
    of backtracking is misused. One could make a case for discouragement
    (though not a case for forbidding them).

    Just my 2c,
    --
    Cameron Simpson <>

    The most annoying thing about being without my files after our disc crash was
    discovering once again how widespread BLINK was on the web.
     
    Cameron Simpson, Oct 6, 2012
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Keith-Earl
    Replies:
    1
    Views:
    462
    Mary Chipman
    Jun 15, 2004
  2. VSK
    Replies:
    2
    Views:
    2,330
  3. =?iso-8859-1?B?bW9vcJk=?=

    Matching abitrary expression in a regular expression

    =?iso-8859-1?B?bW9vcJk=?=, Dec 1, 2005, in forum: Java
    Replies:
    8
    Views:
    860
    Alan Moore
    Dec 2, 2005
  4. GIMME
    Replies:
    3
    Views:
    11,996
    vforvikash
    Dec 29, 2008
  5. Noman Shapiro
    Replies:
    0
    Views:
    239
    Noman Shapiro
    Jul 17, 2013
Loading...

Share This Page