forum for regular expression ? [modified] (ANSWERED)
-
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
-
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
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
-
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
-
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
hhooooohhhh !!! shiny!! :-D Thanks.
This signature was proudly tested on animals.
-
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
-
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
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
-
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
(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.
-
(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.
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
-
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
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.
-
(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.
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.