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 Expresssion

Regular Expresssion

Scheduled Pinned Locked Moved C#
regexhelp
11 Posts 6 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 , I needed to verify that the last 4 digits in a number are 0000. The number was of format 999999-0000 so i checked with a regular expression @"\d-\(0){4}" but now the '-' will not be there and it always just a number with last 4 digits as 0 i.e 0000 I am unable to think of a regular expression to validate this string. any help will be greatly appreciated. Thanks

    P 1 Reply Last reply
    0
    • F fififlowertot

      Hi , I needed to verify that the last 4 digits in a number are 0000. The number was of format 999999-0000 so i checked with a regular expression @"\d-\(0){4}" but now the '-' will not be there and it always just a number with last 4 digits as 0 i.e 0000 I am unable to think of a regular expression to validate this string. any help will be greatly appreciated. Thanks

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

      fififlowertot wrote:

      Hi ,
      I needed to verify that the last 4 digits in a number are 0000.
      The number was of format 999999-0000 so i checked with a regular expression @"\d-\(0){4}"
      but now the '-' will not be there and it always just a number with last 4 digits as 0 i.e 0000
      I am unable to think of a regular expression to validate this string. any help will be greatly appreciated.

      This should have been asked in the Regular Expression forum. However, seeing that the question is here now, and seeing that I'm in a good mood, the regex for this is:

      ^(\d*(0){4})

      [Edited to add deleted question in]

      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

      modified on Thursday, April 7, 2011 12:33 PM

      F G 2 Replies Last reply
      0
      • P Pete OHanlon

        fififlowertot wrote:

        Hi ,
        I needed to verify that the last 4 digits in a number are 0000.
        The number was of format 999999-0000 so i checked with a regular expression @"\d-\(0){4}"
        but now the '-' will not be there and it always just a number with last 4 digits as 0 i.e 0000
        I am unable to think of a regular expression to validate this string. any help will be greatly appreciated.

        This should have been asked in the Regular Expression forum. However, seeing that the question is here now, and seeing that I'm in a good mood, the regex for this is:

        ^(\d*(0){4})

        [Edited to add deleted question in]

        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

        modified on Thursday, April 7, 2011 12:33 PM

        F Offline
        F Offline
        fififlowertot
        wrote on last edited by
        #3

        yeah i was just deleting this when the mail of a reply came in inbox. thanx.

        P P 2 Replies Last reply
        0
        • F fififlowertot

          yeah i was just deleting this when the mail of a reply came in inbox. thanx.

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

          You're welcome.

          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
          • F fififlowertot

            yeah i was just deleting this when the mail of a reply came in inbox. thanx.

            P Offline
            P Offline
            PIEBALDconsult
            wrote on last edited by
            #5

            Don't delete your posts! 0) There is a Regular Expression forum. 1) Have you tried Expresso? 2) Have you tried <a href="http://www.codeproject.com/KB/string/RegexTester\_.aspx">this</a>[<a href="http://www.codeproject.com/KB/string/RegexTester\_.aspx" target="_blank" title="New Window">^</a>]? I don't know why you would want to be capturing the zeroes if you just want to do validation. Did you intend to escape the hyphen (-) rather than the left-parenthesis (() ?

            realJSOPR 1 Reply Last reply
            0
            • P Pete OHanlon

              fififlowertot wrote:

              Hi ,
              I needed to verify that the last 4 digits in a number are 0000.
              The number was of format 999999-0000 so i checked with a regular expression @"\d-\(0){4}"
              but now the '-' will not be there and it always just a number with last 4 digits as 0 i.e 0000
              I am unable to think of a regular expression to validate this string. any help will be greatly appreciated.

              This should have been asked in the Regular Expression forum. However, seeing that the question is here now, and seeing that I'm in a good mood, the regex for this is:

              ^(\d*(0){4})

              [Edited to add deleted question in]

              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

              modified on Thursday, April 7, 2011 12:33 PM

              G Offline
              G Offline
              GenJerDan
              wrote on last edited by
              #6

              Pete O'Hanlon wrote:

              the regex for this is:

              ^(\d*(0){4})

              Send this in to Alex Trebeck for use on Jeopardy, and we'll all guess what the question was. :laugh: "I'll take code fragments for a thousand, Alex."

              There is water at the bottom of the ocean. My Mu[sic] My Films My Windows Programs, etc.

              1 Reply Last reply
              0
              • P PIEBALDconsult

                Don't delete your posts! 0) There is a Regular Expression forum. 1) Have you tried Expresso? 2) Have you tried <a href="http://www.codeproject.com/KB/string/RegexTester\_.aspx">this</a>[<a href="http://www.codeproject.com/KB/string/RegexTester\_.aspx" target="_blank" title="New Window">^</a>]? I don't know why you would want to be capturing the zeroes if you just want to do validation. Did you intend to escape the hyphen (-) rather than the left-parenthesis (() ?

                realJSOPR Offline
                realJSOPR Offline
                realJSOP
                wrote on last edited by
                #7

                PIEBALDconsult wrote:

                Don't delete your posts!

                Unless of course you've come to realize that what you typed makes you look like a complete tool. There are exceptions to every rule. :)

                ".45 ACP - because shooting twice is just silly" - JSOP, 2010
                -----
                You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
                -----
                "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997

                P P 2 Replies Last reply
                0
                • realJSOPR realJSOP

                  PIEBALDconsult wrote:

                  Don't delete your posts!

                  Unless of course you've come to realize that what you typed makes you look like a complete tool. There are exceptions to every rule. :)

                  ".45 ACP - because shooting twice is just silly" - JSOP, 2010
                  -----
                  You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
                  -----
                  "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997

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

                  Is this what's meant by a regular expression tool?

                  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

                  A 1 Reply Last reply
                  0
                  • P Pete OHanlon

                    Is this what's meant by a regular expression tool?

                    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

                    A Offline
                    A Offline
                    AspDotNetDev
                    wrote on last edited by
                    #9

                    The CCC?

                    [WikiLeaks Cablegate Cables]

                    P 1 Reply Last reply
                    0
                    • A AspDotNetDev

                      The CCC?

                      [WikiLeaks Cablegate Cables]

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

                      Dalek Dave's a tool? You could well be right. ;)

                      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
                      • realJSOPR realJSOP

                        PIEBALDconsult wrote:

                        Don't delete your posts!

                        Unless of course you've come to realize that what you typed makes you look like a complete tool. There are exceptions to every rule. :)

                        ".45 ACP - because shooting twice is just silly" - JSOP, 2010
                        -----
                        You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
                        -----
                        "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997

                        P Offline
                        P Offline
                        PIEBALDconsult
                        wrote on last edited by
                        #11

                        No, not even then. And, no there are not.

                        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