regular expressin help

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • prisesh26
    New Member
    • Sep 2006
    • 29

    regular expressin help

    hi,

    i need to frame a regular expression which should accept like the following string
    23MN90
    324378
    43T7N0


    can any one help me


    i tried with al but it is giving false as the result.
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    What do these Strings have in common? Same length? All just letters or digits?

    kind regards,

    Jos

    Comment

    • prisesh26
      New Member
      • Sep 2006
      • 29

      #3
      hi,


      its of length 6. it can have only letters and numbers

      no special characters are allowed

      Comment

      • JosAH
        Recognized Expert MVP
        • Mar 2007
        • 11453

        #4
        Originally posted by prisesh26
        hi,


        its of length 6. it can have only letters and numbers

        no special characters are allowed
        Well, you could've checked the Pattern class for the details of regular
        expressions; this one does the job: "[0-9A-Za-z]{6}".

        kind regards,

        Jos

        Comment

        • prisesh26
          New Member
          • Sep 2006
          • 29

          #5
          Originally posted by JosAH
          Well, you could've checked the Pattern class for the details of regular
          expressions; this one does the job: "[0-9A-Za-z]{6}".

          kind regards,

          Jos

          hi,
          the exp "[0-9A-Za-z]{6}" is accepting special symbols.

          Comment

          • JosAH
            Recognized Expert MVP
            • Mar 2007
            • 11453

            #6
            Originally posted by prisesh26
            hi,
            the exp "[0-9A-Za-z]{6}" is accepting special symbols.
            What special symbols?

            kind regards,

            Jos

            Comment

            • prisesh26
              New Member
              • Sep 2006
              • 29

              #7
              hi Jos,

              I mean special characters like ~!@#$%^ as special symbols.

              i tried with"^[0-9]+[A-Z0-9]+[0-9]+$"


              its working fine.

              thanks yar!!!

              Pri

              Comment

              • JosAH
                Recognized Expert MVP
                • Mar 2007
                • 11453

                #8
                Originally posted by prisesh26
                hi Jos,

                I mean special characters like ~!@#$%^ as special symbols.

                i tried with"^[0-9]+[A-Z0-9]+[0-9]+$"


                its working fine.

                thanks yar!!!

                Pri
                The regular expression you're using now doesn't fit the description you gave us:
                that thing accepts only strings starting and ending with at least one digit, and
                the string doesn't need to be six characters long.

                kind regards,

                Jos

                Comment

                Working...