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 [modified]

regular expression [modified]

Scheduled Pinned Locked Moved ASP.NET
helpregex
10 Posts 4 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
    Sonia Gupta
    wrote on last edited by
    #1

    following is the regular expression which i a using for the whole numbers and fractionl numbers(1 , 2 , 9999 , 3.9 , .8 , .09) [0-9]*.[0-9]* when i tested for the 1s it did not occur any error Please help

    Yesterday is a canceled check. Tomorrow is a promissory note. Today is the ready cash. USE IT.

    modified on Thursday, December 27, 2007 11:55:07 PM

    A 1 Reply Last reply
    0
    • S Sonia Gupta

      following is the regular expression which i a using for the whole numbers and fractionl numbers(1 , 2 , 9999 , 3.9 , .8 , .09) [0-9]*.[0-9]* when i tested for the 1s it did not occur any error Please help

      Yesterday is a canceled check. Tomorrow is a promissory note. Today is the ready cash. USE IT.

      modified on Thursday, December 27, 2007 11:55:07 PM

      A Offline
      A Offline
      aswini
      wrote on last edited by
      #2

      Hi.. Try this [0-9]*[.][0-9]*

      Aswini

      S 1 Reply Last reply
      0
      • A aswini

        Hi.. Try this [0-9]*[.][0-9]*

        Aswini

        S Offline
        S Offline
        Sonia Gupta
        wrote on last edited by
        #3

        ThanQ. I wanted that textbox can accept both whole numbers as well as te fractional numbers The expression , which u provided , excepts only fractional values

        Yesterday is a canceled check. Tomorrow is a promissory note. Today is the ready cash. USE IT.

        S N 2 Replies Last reply
        0
        • S Sonia Gupta

          ThanQ. I wanted that textbox can accept both whole numbers as well as te fractional numbers The expression , which u provided , excepts only fractional values

          Yesterday is a canceled check. Tomorrow is a promissory note. Today is the ready cash. USE IT.

          S Offline
          S Offline
          sulabh2020
          wrote on last edited by
          #4

          here is ur solution, "^[1-9]+[0-9]*(\.{1}[0-9]+)?"

          Hello Forum Always be in touch to help about the topic ASP.NET

          N 1 Reply Last reply
          0
          • S Sonia Gupta

            ThanQ. I wanted that textbox can accept both whole numbers as well as te fractional numbers The expression , which u provided , excepts only fractional values

            Yesterday is a canceled check. Tomorrow is a promissory note. Today is the ready cash. USE IT.

            N Offline
            N Offline
            N a v a n e e t h
            wrote on last edited by
            #5

            Sonia Gupta wrote:

            I wanted that textbox can accept both whole numbers as well as te fractional numbers

            \b[\d]+$|\A([\d]+[\.]{1}[\d]+$|[\.]{1}[\d]+$)

            This accepts the following patterns 17.12 .12 0.25 etc..

            All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia My Website | Ask smart questions

            S 1 Reply Last reply
            0
            • S sulabh2020

              here is ur solution, "^[1-9]+[0-9]*(\.{1}[0-9]+)?"

              Hello Forum Always be in touch to help about the topic ASP.NET

              N Offline
              N Offline
              N a v a n e e t h
              wrote on last edited by
              #6

              sulabh2020 wrote:

              ^[1-9]+[0-9]*(\.{1}[0-9]+)?

              This is incorrect for the expected problem. This will fail to match 0.25 , 25.2255255555555555s. If any text characters appeared in between the number, this expression will match the number part. If won't fail when character appears in between.

              All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia My Website | Ask smart questions

              1 Reply Last reply
              0
              • N N a v a n e e t h

                Sonia Gupta wrote:

                I wanted that textbox can accept both whole numbers as well as te fractional numbers

                \b[\d]+$|\A([\d]+[\.]{1}[\d]+$|[\.]{1}[\d]+$)

                This accepts the following patterns 17.12 .12 0.25 etc..

                All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia My Website | Ask smart questions

                S Offline
                S Offline
                Sonia Gupta
                wrote on last edited by
                #7

                Navaneeth , i want the basic book for regular expressions.Can u please refer me any one , a very basic especially for regular expressions.U know the expression u gave, i am not being able to understand it. If u can make me understand this term . ThanQ

                Yesterday is a canceled check. Tomorrow is a promissory note. Today is the ready cash. USE IT.

                N 1 Reply Last reply
                0
                • S Sonia Gupta

                  Navaneeth , i want the basic book for regular expressions.Can u please refer me any one , a very basic especially for regular expressions.U know the expression u gave, i am not being able to understand it. If u can make me understand this term . ThanQ

                  Yesterday is a canceled check. Tomorrow is a promissory note. Today is the ready cash. USE IT.

                  N Offline
                  N Offline
                  N a v a n e e t h
                  wrote on last edited by
                  #8

                  Sonia Gupta wrote:

                  Navaneeth , i want the basic book for regular expressions.Can u please refer me any one

                  I don't know any good books for regular expression. You can try RegExBuddy. It's good program which helps to write regular expressions.

                  Sonia Gupta wrote:

                  If u can make me understand this term .

                  I will try. Following is the explanation for above regular expression. I will split the above expression into small expressions, that is easy to understand. \b[\d]+$ : This matches any digit in between 0-9 unlimited times. So matches all 12 , 1234 , 12345 etc. This won't match 125s or s584. So real number part is done. Now we need expression for fractional numbers. Bear it in mind, fractional numbers could be written in two ways, 12.32 and .32. Below is the expression which matches fractional numbers. \A([\d]+[\.]{1}[\d]+$|[\.]{1}[\d]+$) : This contains two nested expressions for two types of fractional numbers. First one is ([\d]+[\.]{1}[\d]+$ : which matches 0.25 , 12.25 etc. This fails to match .25 , 0..25. [\.]{1}[\d]+$) this is the second nested expression which matches any number starts with . symbol (.123,.87). These two expressions are combined using or(|) operator. SO if first one fails, regex engine will look for a match with second one. In the same way these two expressions are combined with the first expression using another or operator. So regex engine will look for a real number without any decimal points first. If that one fails, it will enter into the second expression. Second expression is nested, so it will look for match with the first regex, and when it fails it will move to second. If all these fails, entire expression will be failed. \A Asserts position at the beginning $ Asserts position at the end Hope it helps

                  All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia My Website | Ask smart questions

                  S 1 Reply Last reply
                  0
                  • N N a v a n e e t h

                    Sonia Gupta wrote:

                    Navaneeth , i want the basic book for regular expressions.Can u please refer me any one

                    I don't know any good books for regular expression. You can try RegExBuddy. It's good program which helps to write regular expressions.

                    Sonia Gupta wrote:

                    If u can make me understand this term .

                    I will try. Following is the explanation for above regular expression. I will split the above expression into small expressions, that is easy to understand. \b[\d]+$ : This matches any digit in between 0-9 unlimited times. So matches all 12 , 1234 , 12345 etc. This won't match 125s or s584. So real number part is done. Now we need expression for fractional numbers. Bear it in mind, fractional numbers could be written in two ways, 12.32 and .32. Below is the expression which matches fractional numbers. \A([\d]+[\.]{1}[\d]+$|[\.]{1}[\d]+$) : This contains two nested expressions for two types of fractional numbers. First one is ([\d]+[\.]{1}[\d]+$ : which matches 0.25 , 12.25 etc. This fails to match .25 , 0..25. [\.]{1}[\d]+$) this is the second nested expression which matches any number starts with . symbol (.123,.87). These two expressions are combined using or(|) operator. SO if first one fails, regex engine will look for a match with second one. In the same way these two expressions are combined with the first expression using another or operator. So regex engine will look for a real number without any decimal points first. If that one fails, it will enter into the second expression. Second expression is nested, so it will look for match with the first regex, and when it fails it will move to second. If all these fails, entire expression will be failed. \A Asserts position at the beginning $ Asserts position at the end Hope it helps

                    All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia My Website | Ask smart questions

                    S Offline
                    S Offline
                    Sonia Gupta
                    wrote on last edited by
                    #9

                    instead of \b[\d]+$ can i write [0-9]* if yes what's the meaning of \b and \d

                    Yesterday is a canceled check. Tomorrow is a promissory note. Today is the ready cash. USE IT.

                    N 1 Reply Last reply
                    0
                    • S Sonia Gupta

                      instead of \b[\d]+$ can i write [0-9]* if yes what's the meaning of \b and \d

                      Yesterday is a canceled check. Tomorrow is a promissory note. Today is the ready cash. USE IT.

                      N Offline
                      N Offline
                      N a v a n e e t h
                      wrote on last edited by
                      #10

                      Sonia Gupta wrote:

                      instead of \b[\d]+$ can i write [0-9]*

                      No instead of [\d]+ you can write [0-9]*. \b is asserting position at the word boundaries. \d matches any number from 0-9.

                      All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia My Website | Ask smart questions

                      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