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. The Lounge
  3. forum for regular expression ? [modified] (ANSWERED)

forum for regular expression ? [modified] (ANSWERED)

Scheduled Pinned Locked Moved The Lounge
helpcsharpc++pythonperl
10 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
    Maximilien
    wrote on last edited by
    #1

    I've got a few questions about regular expressions to be used with tr1::regexp. I could do it in the C++ forum, but I'm not certain I will get much audience. in which forum to go to ? C#, Perl, Python or coding horror :doh: ? Thanks a bunch. Thanks to Jim Crafton & OriginalGriff I was able to fix a quick R.E. problem.

    This signature was proudly tested on animals.

    modified on Thursday, September 3, 2009 4:13 PM

    J S 2 Replies Last reply
    0
    • M Maximilien

      I've got a few questions about regular expressions to be used with tr1::regexp. I could do it in the C++ forum, but I'm not certain I will get much audience. in which forum to go to ? C#, Perl, Python or coding horror :doh: ? Thanks a bunch. Thanks to Jim Crafton & OriginalGriff I was able to fix a quick R.E. problem.

      This signature was proudly tested on animals.

      modified on Thursday, September 3, 2009 4:13 PM

      J Offline
      J Offline
      Jim Crafton
      wrote on last edited by
      #2

      One thing you might check out is this: Regex Coach[^] It's a small utility that lets you type in a reg ex and see and step through the results on some text that you can also enter. It's been a *HUGE* help for me, because I'm always forgetting some bit of regex rules, since I don't use them that often.

      ¡El diablo está en mis pantalones! ¡Mire, mire! SELECT * FROM User WHERE Clue > 0 0 rows returned Save an Orange - Use the VCF! Personal 3D projects Just Say No to Web 2 Point Blow

      OriginalGriffO M 2 Replies Last reply
      0
      • J Jim Crafton

        One thing you might check out is this: Regex Coach[^] It's a small utility that lets you type in a reg ex and see and step through the results on some text that you can also enter. It's been a *HUGE* help for me, because I'm always forgetting some bit of regex rules, since I don't use them that often.

        ¡El diablo está en mis pantalones! ¡Mire, mire! SELECT * FROM User WHERE Clue > 0 0 rows returned Save an Orange - Use the VCF! Personal 3D projects Just Say No to Web 2 Point Blow

        OriginalGriffO Offline
        OriginalGriffO Offline
        OriginalGriff
        wrote on last edited by
        #3

        Or try Expresso[^] - examines and generates regular expressions. (Thanks to Henry Minute for this one.)

        No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced. This message is made of fully recyclable Zeros and Ones

        "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
        "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

        J 1 Reply Last reply
        0
        • J Jim Crafton

          One thing you might check out is this: Regex Coach[^] It's a small utility that lets you type in a reg ex and see and step through the results on some text that you can also enter. It's been a *HUGE* help for me, because I'm always forgetting some bit of regex rules, since I don't use them that often.

          ¡El diablo está en mis pantalones! ¡Mire, mire! SELECT * FROM User WHERE Clue > 0 0 rows returned Save an Orange - Use the VCF! Personal 3D projects Just Say No to Web 2 Point Blow

          M Offline
          M Offline
          Maximilien
          wrote on last edited by
          #4

          hhooooohhhh !!! shiny!! :-D Thanks.

          This signature was proudly tested on animals.

          1 Reply Last reply
          0
          • OriginalGriffO OriginalGriff

            Or try Expresso[^] - examines and generates regular expressions. (Thanks to Henry Minute for this one.)

            No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced. This message is made of fully recyclable Zeros and Ones

            J Offline
            J Offline
            Jim Crafton
            wrote on last edited by
            #5

            Cool link, thanks!

            ¡El diablo está en mis pantalones! ¡Mire, mire! SELECT * FROM User WHERE Clue > 0 0 rows returned Save an Orange - Use the VCF! Personal 3D projects Just Say No to Web 2 Point Blow

            1 Reply Last reply
            0
            • M Maximilien

              I've got a few questions about regular expressions to be used with tr1::regexp. I could do it in the C++ forum, but I'm not certain I will get much audience. in which forum to go to ? C#, Perl, Python or coding horror :doh: ? Thanks a bunch. Thanks to Jim Crafton & OriginalGriff I was able to fix a quick R.E. problem.

              This signature was proudly tested on animals.

              modified on Thursday, September 3, 2009 4:13 PM

              S Offline
              S Offline
              Stuart Dootson
              wrote on last edited by
              #6

              Maximilien wrote:

              I could do it in the C++ forum

              I'd have a go at answering your question there! tr1::regexes aren't a lot different from the Boost ones :-)

              Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

              M 1 Reply Last reply
              0
              • S Stuart Dootson

                Maximilien wrote:

                I could do it in the C++ forum

                I'd have a go at answering your question there! tr1::regexes aren't a lot different from the Boost ones :-)

                Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

                M Offline
                M Offline
                Maximilien
                wrote on last edited by
                #7

                (maybe this is basic, but ...) I'm trying to parse a string like (1.2, 3.4, -5.6) : triplet of float numbers inside parenthesis. I was wondering if there is a simpler way to do it : the string that I use now is large, a lot of it is to "ignore" blanks (I could remove them from the input before parsing), and the 3 big float number patterns

                (\s*)\((\s*)[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?(\s*),(\s*)[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?(\s*),(\s*)[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?(\s*)\)(\s*)

                This signature was proudly tested on animals.

                S P 2 Replies Last reply
                0
                • M Maximilien

                  (maybe this is basic, but ...) I'm trying to parse a string like (1.2, 3.4, -5.6) : triplet of float numbers inside parenthesis. I was wondering if there is a simpler way to do it : the string that I use now is large, a lot of it is to "ignore" blanks (I could remove them from the input before parsing), and the 3 big float number patterns

                  (\s*)\((\s*)[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?(\s*),(\s*)[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?(\s*),(\s*)[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?(\s*)\)(\s*)

                  This signature was proudly tested on animals.

                  S Offline
                  S Offline
                  Stuart Dootson
                  wrote on last edited by
                  #8

                  I'd almost be tempted to go with Boost.Spirit for that :-) Alternatively, build the RE string up in chunks:

                  std::string number = "[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?";
                  std::string spaces="(\s*)";

                  std::tr1::regex reTriplet(spaces + "\(" + spaces + number + spaces + "," + spaces + number + spaces + "," + spaces + number + spaces + "\)" + spaces);

                  Slightly clearer than using a single literal sting maybe? Also, you could use \d rather than [0-9] (but you need to escape the \).

                  Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

                  M 1 Reply Last reply
                  0
                  • S Stuart Dootson

                    I'd almost be tempted to go with Boost.Spirit for that :-) Alternatively, build the RE string up in chunks:

                    std::string number = "[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?";
                    std::string spaces="(\s*)";

                    std::tr1::regex reTriplet(spaces + "\(" + spaces + number + spaces + "," + spaces + number + spaces + "," + spaces + number + spaces + "\)" + spaces);

                    Slightly clearer than using a single literal sting maybe? Also, you could use \d rather than [0-9] (but you need to escape the \).

                    Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

                    M Offline
                    M Offline
                    Maximilien
                    wrote on last edited by
                    #9

                    I'd love to boost our software, but there's no time for that now! (unfortunatly!) Thanks, yeah, I could split that into small readable chunks! :-D

                    This signature was proudly tested on animals.

                    1 Reply Last reply
                    0
                    • M Maximilien

                      (maybe this is basic, but ...) I'm trying to parse a string like (1.2, 3.4, -5.6) : triplet of float numbers inside parenthesis. I was wondering if there is a simpler way to do it : the string that I use now is large, a lot of it is to "ignore" blanks (I could remove them from the input before parsing), and the 3 big float number patterns

                      (\s*)\((\s*)[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?(\s*),(\s*)[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?(\s*),(\s*)[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?(\s*)\)(\s*)

                      This signature was proudly tested on animals.

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

                      Why are you grouping the whitespace? Why are you not grouping the numbers? I would change that to: \(\s*(?'First'([-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?))\s*,\s*(?'Second'([-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?))\s*,\s*(?'Third'([-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?))\s*\) And use the ExplicitCapture option. I used my RegexTester[^] to work on that.

                      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