regular expression question (re module)

Discussion in 'Python' started by Faheem Mitha, Oct 11, 2008.

  1. Faheem Mitha

    Faheem Mitha Guest

    Hi,

    I need to match a string of the form

    capital_letter underscore capital_letter number

    against a string of the form

    anything capital_letter underscore capital_letter number
    some_stuff_not_starting with a number

    Eg D_A1 needs to match with DUKE00001_plateD_A1.CEL, but not any of
    DUKE00001_plateD_A10.CEL, Duke00001_PlateD_A11v2.CEL,
    DUKE00001_plateD_A12.CEL.

    Similarly D_A10 needs to match DUKE00001_plateD_A10.CEL, but not any
    of DUKE00001_plateD_A1.CEL, Duke00001_PlateD_A11v2.CEL,
    DUKE00001_plateD_A12.CEL.

    Similarly D_A11 needs to match Duke00001_PlateD_A11v2.CEL, but not any
    of DUKE00001_plateD_A1.CEL, DUKE00001_plateD_A10.CEL,
    DUKE00001_plateD_A12.CEL.

    Thanks in advance. Please cc me with any reply.
    Faheem.
     
    Faheem Mitha, Oct 11, 2008
    #1
    1. Advertising

  2. Faheem Mitha

    Guest

    Faheem Mitha:
    > I need to match a string of the form
    > ...


    Please, show the code you have written so far, with your input-output
    examples included (as doctests, for example), and we can try to find
    ways to help you remove the bugs you have.

    Bye,
    bearophile
     
    , Oct 11, 2008
    #2
    1. Advertising

  3. Faheem Mitha

    Steve Holden Guest

    Pat wrote:
    > Faheem Mitha wrote:
    >> Hi,
    >>
    >> I need to match a string of the form
    >>
    >> capital_letter underscore capital_letter number
    >>
    >> against a string of the form
    >>
    >> anything capital_letter underscore capital_letter number
    >> some_stuff_not_starting with a number
    >>

    > <snip>
    >> DUKE00001_plateD_A12.CEL.
    >>
    >> Thanks in advance. Please cc me with any reply.
    >> Faheem.
    >>

    >
    > While I can't provide you with an answer, I can say that I've been using
    > RegExBuddy (for Windows, about $40, 90 day money back guarantee,
    > http://www.regexbuddy.com/) for quite a few months now and it's greatly
    > helped me with creating/learning/debugging regexps. You put in your
    > regexp in the top field and all the possibilities in the bottom field.
    > Whatever matches is instantly highlighted. You keep modifying your RE
    > until only the correct matches are highlighted. Talk about instant
    > gratification! No, I'm in no way affiliated with this company.
    >
    > There's also a free *IX version that's quite similar to RegExBuddy but I
    > don't have the name since I'm writing this while on a Windows platform.
    > --
    > http://mail.python.org/mailman/listinfo/python-list
    >

    Or you could use the Kodos tool, written in Python and well worth a
    trial since it's free. Google is, as always, your friend in locating it.

    regards
    Steve
    --
    Steve Holden +1 571 484 6266 +1 800 494 3119
    Holden Web LLC http://www.holdenweb.com/
     
    Steve Holden, Oct 17, 2008
    #3
  4. On Oct 16, 2008, at 11:25 PM, Steve Holden wrote:

    > Pat wrote:
    >> Faheem Mitha wrote:
    >>> Hi,
    >>>
    >>> I need to match a string of the form
    >>>
    >>> capital_letter underscore capital_letter number
    >>>
    >>> against a string of the form
    >>>
    >>> anything capital_letter underscore capital_letter number
    >>> some_stuff_not_starting with a number
    >>>

    >> <snip>
    >>> DUKE00001_plateD_A12.CEL.
    >>>
    >>> Thanks in advance. Please cc me with any reply.
    >>>
    >>> Faheem.
    >>>

    >>
    >> While I can't provide you with an answer, I can say that I've been
    >> using
    >> RegExBuddy (for Windows, about $40, 90 day money back guarantee,
    >> http://www.regexbuddy.com/) for quite a few months now and it's
    >> greatly
    >> helped me with creating/learning/debugging regexps. You put in your
    >> regexp in the top field and all the possibilities in the bottom
    >> field.
    >> Whatever matches is instantly highlighted. You keep modifying your
    >> RE
    >> until only the correct matches are highlighted. Talk about instant
    >> gratification! No, I'm in no way affiliated with this company.
    >>
    >> There's also a free *IX version that's quite similar to RegExBuddy
    >> but I
    >> don't have the name since I'm writing this while on a Windows
    >> platform.
    >> --
    >> http://mail.python.org/mailman/listinfo/python-list
    >>

    > Or you could use the Kodos tool, written in Python and well worth a
    > trial since it's free. Google is, as always, your friend in locating
    > it.



    I use this one as my regex playground:
    http://cthedot.de/retest/
     
    Philip Semanchuk, Oct 17, 2008
    #4
  5. Faheem Mitha

    Pat Guest

    Faheem Mitha wrote:
    > Hi,
    >
    > I need to match a string of the form
    >
    > capital_letter underscore capital_letter number
    >
    > against a string of the form
    >
    > anything capital_letter underscore capital_letter number
    > some_stuff_not_starting with a number
    >

    <snip>
    > DUKE00001_plateD_A12.CEL.
    >
    > Thanks in advance. Please cc me with any reply.
    > Faheem.
    >


    While I can't provide you with an answer, I can say that I've been using
    RegExBuddy (for Windows, about $40, 90 day money back guarantee,
    http://www.regexbuddy.com/) for quite a few months now and it's greatly
    helped me with creating/learning/debugging regexps. You put in your
    regexp in the top field and all the possibilities in the bottom field.
    Whatever matches is instantly highlighted. You keep modifying your RE
    until only the correct matches are highlighted. Talk about instant
    gratification! No, I'm in no way affiliated with this company.

    There's also a free *IX version that's quite similar to RegExBuddy but I
    don't have the name since I'm writing this while on a Windows platform.
     
    Pat, Oct 17, 2008
    #5
    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. VSK
    Replies:
    2
    Views:
    2,390
  2. =?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:
    884
    Alan Moore
    Dec 2, 2005
  3. GIMME
    Replies:
    3
    Views:
    12,050
    vforvikash
    Dec 29, 2008
  4. Steve
    Replies:
    11
    Views:
    574
    Jim Segrave
    Jul 1, 2006
  5. Walter Roberson

    regular expression module?

    Walter Roberson, Apr 20, 2004, in forum: Perl Misc
    Replies:
    12
    Views:
    182
    Walter Roberson
    Apr 22, 2004
Loading...

Share This Page