Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Regular Expressions
  4. regex code assistance for entering 600 in a input field

regex code assistance for entering 600 in a input field

Scheduled Pinned Locked Moved Regular Expressions
regexhelptutorialquestion
7 Posts 3 Posters 22 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Member_15683654
    wrote on last edited by
    #1

    Hello I was trying to understand how to work with a regex expression for when a User enters starts typing in 600 in the input field, then populate the error message. What would be the regex code for that?
    Currently I have `^[\w'\-,.][^0-9_!¡?÷?¿\/\\+=@#$%ˆ&*(){}|~<>;:[\]]{2,}$`

    L 1 Reply Last reply
    0
    • M Member_15683654

      Hello I was trying to understand how to work with a regex expression for when a User enters starts typing in 600 in the input field, then populate the error message. What would be the regex code for that?
      Currently I have `^[\w'\-,.][^0-9_!¡?÷?¿\/\\+=@#$%ˆ&*(){}|~<>;:[\]]{2,}$`

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Do you really need all that just to capture "600"?

      M 1 Reply Last reply
      0
      • L Lost User

        Do you really need all that just to capture "600"?

        M Offline
        M Offline
        Member_15683654
        wrote on last edited by
        #3

        thank you for your reply:

        Main thing is if customer enters a credit card like 1111222233334444 that is ok, but if customer enters a credit card number that starts with 600 and then other characters then it should be validated. ex: 6001222233334444

        L 1 Reply Last reply
        0
        • M Member_15683654

          thank you for your reply:

          Main thing is if customer enters a credit card like 1111222233334444 that is ok, but if customer enters a credit card number that starts with 600 and then other characters then it should be validated. ex: 6001222233334444

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          In that case it would be easier just to check if the first 3 characters are "600"; and you can do that with a simple string method in most languages.

          M 1 Reply Last reply
          0
          • L Lost User

            In that case it would be easier just to check if the first 3 characters are "600"; and you can do that with a simple string method in most languages.

            M Offline
            M Offline
            Member_15683654
            wrote on last edited by
            #5

            How would I do that? I tried with

            ^600

            but it instead it didnt show that error but got rid of it. I want to show the error when customer enters 600 first and any numbers after.

            Richard DeemingR L 2 Replies Last reply
            0
            • M Member_15683654

              How would I do that? I tried with

              ^600

              but it instead it didnt show that error but got rid of it. I want to show the error when customer enters 600 first and any numbers after.

              Richard DeemingR Offline
              Richard DeemingR Offline
              Richard Deeming
              wrote on last edited by
              #6

              Looks like you're specifying the pattern for valid values, rather than invalid values. Try:

              ^([^6]|6[^0]|60[^0])

              Regexper[^] regex101: build, test, and debug regex[^]


              "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

              "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

              1 Reply Last reply
              0
              • M Member_15683654

                How would I do that? I tried with

                ^600

                but it instead it didnt show that error but got rid of it. I want to show the error when customer enters 600 first and any numbers after.

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #7

                Why do you need a regex for such a simple test?

                if (text.substring(0, 3).equals("600")) // is all you need
                ...

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups