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. Decimal(18,2) Regular Expression

Decimal(18,2) Regular Expression

Scheduled Pinned Locked Moved ASP.NET
regex
7 Posts 5 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.
  • M Offline
    M Offline
    Mr Sam
    wrote on last edited by
    #1

    Hi all, Can anyone tell me a regular expression to validate a decimal(18,2). Thanks

    Bye

    C K 2 Replies Last reply
    0
    • M Mr Sam

      Hi all, Can anyone tell me a regular expression to validate a decimal(18,2). Thanks

      Bye

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      \d{1,18}\.?\d{0,2} At a guess.

      Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

      1 Reply Last reply
      0
      • M Mr Sam

        Hi all, Can anyone tell me a regular expression to validate a decimal(18,2). Thanks

        Bye

        K Offline
        K Offline
        kapil bhatnagar
        wrote on last edited by
        #3

        ^[-]?([1-9]{1}[0-9]{0,}(\.[0-9]{0,2})?|0(\.[0-9]{0,2})?|\.[0-9]{1,2})$ This regular expression will match on a real / decimal / floating point / numeric string with no more than 2 digits past the decimal. The negative sign (-) is allowed. No leading zeroes or commas or use the following link: http://regexlib.com for further search

        M 1 Reply Last reply
        0
        • K kapil bhatnagar

          ^[-]?([1-9]{1}[0-9]{0,}(\.[0-9]{0,2})?|0(\.[0-9]{0,2})?|\.[0-9]{1,2})$ This regular expression will match on a real / decimal / floating point / numeric string with no more than 2 digits past the decimal. The negative sign (-) is allowed. No leading zeroes or commas or use the following link: http://regexlib.com for further search

          M Offline
          M Offline
          Mr Sam
          wrote on last edited by
          #4

          Will it be restricting the value to maximum 16 digits before decimal? -- modified at 5:16 Monday 22nd October, 2007

          Bye

          K C 2 Replies Last reply
          0
          • M Mr Sam

            Will it be restricting the value to maximum 16 digits before decimal? -- modified at 5:16 Monday 22nd October, 2007

            Bye

            K Offline
            K Offline
            kapil bhatnagar
            wrote on last edited by
            #5

            the previous one will not... try this one : ^[-]?([1-9]{1,18}[0-9]{0,}(\.[0-9]{0,2})?|0(\.[0-9]{0,2})?|\.[0-9]{1,2})$

            1 Reply Last reply
            0
            • M Mr Sam

              Will it be restricting the value to maximum 16 digits before decimal? -- modified at 5:16 Monday 22nd October, 2007

              Bye

              C Offline
              C Offline
              Chetan Patel
              wrote on last edited by
              #6

              "\d{0,18}\.?\d{0,2}"

              Best Regards, Chetan Patel

              J 1 Reply Last reply
              0
              • C Chetan Patel

                "\d{0,18}\.?\d{0,2}"

                Best Regards, Chetan Patel

                J Offline
                J Offline
                jaysaran
                wrote on last edited by
                #7

                Try this. I think this is exact one "\d{0,16}(\.\d{1,2})?"

                Best Regards

                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