Combining 2 regexes to 1

Discussion in 'Python' started by Niklasro(.appspot), Aug 30, 2010.

  1. Hello, Suspecting it's completely doable combining these 2 regexes to
    just 1 expression I'm looking for the working syntax. If you know then
    kindly inform. Thanks in advance
    ('/a/([^/]*)',List), #list
    ('/a([^/]*)',List), #list
    Niklas Rosencrantz
     
    Niklasro(.appspot), Aug 30, 2010
    #1
    1. Advertising

  2. Niklasro(.appspot)

    Chris Rebert Guest

    On Sun, Aug 29, 2010 at 7:40 PM, Niklasro(.appspot) <> wrote:
    > Hello, Suspecting it's completely doable combining these 2 regexes to
    > just 1 expression I'm looking for the working syntax. If you know then
    > kindly inform. Thanks in advance
    > ('/a/([^/]*)',List), #list
    > ('/a([^/]*)',List), #list


    Er,

    /a(/?)([^/]*)

    ?

    Cheers,
    Chris
    --
    Parentheses probably extraneous.
     
    Chris Rebert, Aug 30, 2010
    #2
    1. Advertising

  3. Niklasro(.appspot)

    MRAB Guest

    On 30/08/2010 03:40, Niklasro(.appspot) wrote:
    > Hello, Suspecting it's completely doable combining these 2 regexes to
    > just 1 expression I'm looking for the working syntax. If you know then
    > kindly inform. Thanks in advance
    > ('/a/([^/]*)',List), #list
    > ('/a([^/]*)',List), #list


    ('/a/?([^/]*)', List), #list
     
    MRAB, Aug 30, 2010
    #3
  4. Many thanks. It works. You also helped me refactor these

    ('/([0-9]*)/?([^/]*)',AById),#id2a
    ('/([0-9]*)',AById)

    to just 1

    ('/([0-9]*)/?([^/]*)',AById),#id2a

    It's from the appspot framework.
    Sincerely
    Niklas R
     
    Niklasro(.appspot), Aug 30, 2010
    #4
    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. Roedy Green

    File.separatorChar and regexes.

    Roedy Green, Aug 22, 2003, in forum: Java
    Replies:
    0
    Views:
    1,812
    Roedy Green
    Aug 22, 2003
  2. Jason Smith

    Does Python optimize regexes?

    Jason Smith, Jun 29, 2004, in forum: Python
    Replies:
    5
    Views:
    324
  3. Klaus Neuner
    Replies:
    7
    Views:
    505
    Klaus Neuner
    Jul 26, 2004
  4. Fernando Rodriguez

    Trouble with regexes

    Fernando Rodriguez, May 25, 2005, in forum: Python
    Replies:
    2
    Views:
    341
    Tim Roberts
    May 27, 2005
  5. Ara.T.Howard

    MoinMoin WikiName and python regexes

    Ara.T.Howard, Jun 8, 2005, in forum: Python
    Replies:
    6
    Views:
    969
    Bengt Richter
    Jun 26, 2005
Loading...

Share This Page