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. C#
  4. Regular Expression Help

Regular Expression Help

Scheduled Pinned Locked Moved C#
regexquestionhelplearning
3 Posts 2 Posters 0 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.
  • D Offline
    D Offline
    David Flores
    wrote on last edited by
    #1

    Hi all. I have the following regular expression pattern that I go t from a book. ^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,10}$ The book says this is suppose to validate atleast 1 uppercase, 1 lowercase, 1 digit, no special characters and between 8 and 10 characters. So "hello123" is not valid, but "Hello123" is valid. Unfortunately "Hello 123" or "Hello@123" are also valid, but should be invalid. What is the correct regular expression syntax? Thanks in advance

    J 1 Reply Last reply
    0
    • D David Flores

      Hi all. I have the following regular expression pattern that I go t from a book. ^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,10}$ The book says this is suppose to validate atleast 1 uppercase, 1 lowercase, 1 digit, no special characters and between 8 and 10 characters. So "hello123" is not valid, but "Hello123" is valid. Unfortunately "Hello 123" or "Hello@123" are also valid, but should be invalid. What is the correct regular expression syntax? Thanks in advance

      J Offline
      J Offline
      John Fisher
      wrote on last edited by
      #2

      Hi, In my quick testing, this change achived the desired goal (note that the last "." was replaced with "[0-9,a-z,A-Z]". I don't know all the terms used in working with regular expressions, but I suspect that this answer along with the book you are reading will give you an understanding of the situation!

      ^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])[0-9,a-z,A-Z]{8,10}$

      John
      "You said a whole sentence with no words in it, and I understood you!" -- my wife as she cries about slowly becoming a geek.

      D 1 Reply Last reply
      0
      • J John Fisher

        Hi, In my quick testing, this change achived the desired goal (note that the last "." was replaced with "[0-9,a-z,A-Z]". I don't know all the terms used in working with regular expressions, but I suspect that this answer along with the book you are reading will give you an understanding of the situation!

        ^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])[0-9,a-z,A-Z]{8,10}$

        John
        "You said a whole sentence with no words in it, and I understood you!" -- my wife as she cries about slowly becoming a geek.

        D Offline
        D Offline
        David Flores
        wrote on last edited by
        #3

        Thanks John. It worked great.:-D

        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