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 for a Customer number

Regex for a Customer number

Scheduled Pinned Locked Moved Regular Expressions
regexsaleshelp
3 Posts 3 Posters 9 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
    poornima sadasivan
    wrote on last edited by
    #1

    My Customer number is in the pattern : 88765 ie. 5 digits alone... using regex i have to validate if there are any characters and special characters in the customer number. Incase there are any characters (eg: 8AB90) or special characters then my string is invalid. Please help me with the RegEx for the same.

    S J 2 Replies Last reply
    0
    • P poornima sadasivan

      My Customer number is in the pattern : 88765 ie. 5 digits alone... using regex i have to validate if there are any characters and special characters in the customer number. Incase there are any characters (eg: 8AB90) or special characters then my string is invalid. Please help me with the RegEx for the same.

      S Offline
      S Offline
      SeanChupas
      wrote on last edited by
      #2

      poornima sadasivan wrote:

      validate if there are any characters and special characters in the customer number.

      An easier way it to check to make sure all characters are numbers. This uses LINQ. For example:

      return strVar.All(char.IsDigit);

      1 Reply Last reply
      0
      • P poornima sadasivan

        My Customer number is in the pattern : 88765 ie. 5 digits alone... using regex i have to validate if there are any characters and special characters in the customer number. Incase there are any characters (eg: 8AB90) or special characters then my string is invalid. Please help me with the RegEx for the same.

        J Offline
        J Offline
        jschell
        wrote on last edited by
        #3

        Following should do it in perl, java and C#. ^[0-9]{5}$

        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