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

regular expression

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

    Hi can u help me reach a regular expression which will 1: allow 7 numeric digits or 2: 9 alphanumeric or 9 numeric i tried ([0-9]{7}|[a-zA-Z0-9]{9}|[0-9]{9}) but it doesn't allow 9 numerics. thanks

    P 1 Reply Last reply
    0
    • F fififlowertot

      Hi can u help me reach a regular expression which will 1: allow 7 numeric digits or 2: 9 alphanumeric or 9 numeric i tried ([0-9]{7}|[a-zA-Z0-9]{9}|[0-9]{9}) but it doesn't allow 9 numerics. thanks

      P Offline
      P Offline
      Pete OHanlon
      wrote on last edited by
      #2

      As you already capture the conditions for a numeric only match in the alphanumeric match, you can drop the 9 numbers test and rely on the 9 alpha-numeric test. The key to your solution is to test for the longer character match before you test the shorter match, so your query becomes:

      [a-zA-Z0-9]{9}|[0-9]{7}

      I'm not a stalker, I just know things. Oh by the way, you're out of milk.

      Forgive your enemies - it messes with their heads

      My blog | My articles | MoXAML PowerToys | Onyx

      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