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. Web Development
  3. ASP.NET
  4. Regular expression that rejects empty string.

Regular expression that rejects empty string.

Scheduled Pinned Locked Moved ASP.NET
regexhelpquestion
2 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.
  • P Offline
    P Offline
    paper67
    wrote on last edited by
    #1

    Hi, I have a regular expression for entering decimal values with exactly 2 digits after the comma. [0-9]{1,4},[0-9]{2} "1.34" -> ok "9765.51" -> ok "67453.56" -> nok "-7.45" -> nok "67.1" -> nok "" -> ok I would like that to be nok. My problem is that even when I enter nothing (empty string) it passes the test. How can I prevent this from happening. tia

    B 1 Reply Last reply
    0
    • P paper67

      Hi, I have a regular expression for entering decimal values with exactly 2 digits after the comma. [0-9]{1,4},[0-9]{2} "1.34" -> ok "9765.51" -> ok "67453.56" -> nok "-7.45" -> nok "67.1" -> nok "" -> ok I would like that to be nok. My problem is that even when I enter nothing (empty string) it passes the test. How can I prevent this from happening. tia

      B Offline
      B Offline
      Brij
      wrote on last edited by
      #2

      Check this page http://regexlib.com/\[[^](http://regexlib.com/ "New Window")]"> One thing also you can do before passing it to regex check whether it is empty string and implement accordingly

      Cheers!! Brij

      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