regular expression question (re module)

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Faheem Mitha

    regular expression question (re module)

    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_plate D_A1.CEL, but not any of
    DUKE00001_plate D_A10.CEL, Duke00001_Plate D_A11v2.CEL,
    DUKE00001_plate D_A12.CEL.

    Similarly D_A10 needs to match DUKE00001_plate D_A10.CEL, but not any
    of DUKE00001_plate D_A1.CEL, Duke00001_Plate D_A11v2.CEL,
    DUKE00001_plate D_A12.CEL.

    Similarly D_A11 needs to match Duke00001_Plate D_A11v2.CEL, but not any
    of DUKE00001_plate D_A1.CEL, DUKE00001_plate D_A10.CEL,
    DUKE00001_plate D_A12.CEL.

    Thanks in advance. Please cc me with any reply.
    Faheem.

  • bearophileHUGS@lycos.com

    #2
    Re: regular expression question (re module)

    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

    Comment

    • Pat

      #3
      Re: regular expression question (re module)

      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_plate D_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.

      Comment

      • Steve Holden

        #4
        Re: regular expression question (re module)

        Pat wrote:
        Faheem Mitha wrote:
        >Hi,
        >>
        >I need to match a string of the form
        >>
        >capital_lett er 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_plat eD_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.
        --

        >
        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/

        Comment

        • Philip Semanchuk

          #5
          Re: regular expression question (re module)


          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_lette r underscore capital_letter number
          >>>
          >>against a string of the form
          >>>
          >>anything capital_letter underscore capital_letter number
          >>some_stuff_no t_starting with a number
          >>>
          ><snip>
          >>DUKE00001_pla teD_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
          >gratificatio n! 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:
          cthedot.de - (more official) homepage of Christof Hoeke







          Comment

          Working...