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 in .net

Regular expression in .net

Scheduled Pinned Locked Moved ASP.NET
helpcsharpregexquestion
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.
  • S Offline
    S Offline
    safii
    wrote on last edited by
    #1

    hi i am facing a problem while building a regular expression for a numeric value having data type 9(13,3). The expression i build is "[0-9]{1,10}\.{0,1}[0-9]{0,3}" but the problem occures when i enter a value like "123456789012". It works fine when a value like "1234567890.123" is entered. Can anybody help me out of this prob? safii

    B 1 Reply Last reply
    0
    • S safii

      hi i am facing a problem while building a regular expression for a numeric value having data type 9(13,3). The expression i build is "[0-9]{1,10}\.{0,1}[0-9]{0,3}" but the problem occures when i enter a value like "123456789012". It works fine when a value like "1234567890.123" is entered. Can anybody help me out of this prob? safii

      B Offline
      B Offline
      Blake Coverett
      wrote on last edited by
      #2

      \d{1,10}(?:\.\d{1,3})? Notes: ~ Use \d instead of [0-9] ~ Use ? instead if {0,1} ~ Group the decimal and the following digits so either both or neither must appear. ~ This presumes that you want "123" and "123.1" to be valid, but "123." to be invalid, change the second 1 to a 0 if that's not true. ~ Keep in mind that you need something before and after that expression as well to delimit it. If your numbers were each on a line by themselves, then a ^ on the front and a $ on the end would work. But you need to avoid matching 991111111111.1119 the valid number in the middle of the bigger number there. -Blake

      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