07-14-2010 01:53 PM
I think this answer really deserves a geek award (talking regexpr like other talk klingon):
http://forums.ni.com/t5/LabVIEW/regex-making-my-head-spin/m-p/1181895#M512413
Felix
07-14-2010 02:14 PM
@f. Schubert wrote:
I think this answer really deserves a geek award (talking regexpr like other talk klingon):
http://forums.ni.com/t5/LabVIEW/regex-making-my-head-spin/m-p/1181895#M512413
Felix
I second the motion. Anyone who can come up with an expression like that is not human. ![]()
07-15-2010 12:47 AM
Unbelievable !
07-15-2010 01:40 AM
Where did he............ how is that formula....
..
..
07-15-2010 05:55 AM - edited 07-15-2010 05:56 AM
I love posts about Regular Expressions because they're are so intriguing. Any time I use one, however, I feel that I'm sacrificing readability for (my interpretation of) elegance. Sometimes I feel it would be better to simply pull strings apart and look for stuff the old fashioned way so folks unfamiliar with regexps don't, in an effort to maintain or extend my code, find the regexp, get frustrated with the hieroglyphics and track me down and kill me.
I'd like to do a benchmark on forimstuck's problem, comparing a regexp solution with a more common approach when handling large inputs.
Edit - I put a (somewhat) more readable version on the original thread. I'll explain the regular expressions I used during my lunch hour.
07-15-2010 07:40 AM
Jim,
That regular expression is awesome.
I did follow that thread and got lost when I looked at it. So I decided to copy the code and carry out regexpr experiments on my own and extend my understanding of it. My C code would certainly benefit from knowing more regexpressions and the power behind them.
You'll have to add "RegExpr King" to your signature.
RayR
(regexp novice)
07-15-2010 09:21 AM
@jcarmody wrote:
. Sometimes I feel it would be better to simply pull strings apart and look for stuff the old fashioned way so folks unfamiliar with regexps don't, in an effort to maintain or extend my code, find the regexp, get frustrated with the hieroglyphics and track me down and kill me.
Love the code! mind-blowing! and without a DETAILED comment in the code, preferably with revision history comment blocks (even old regexpr constants and commanets to preserve history in case of back-revision) you would probably need to enter the witness protection program. ![]()
this is a perfect example of Elegance vs Maintainability - I'm sure the repost after lunch will solve that problem elegantly as well. I'm looking forward to reading it!
07-15-2010 10:43 AM - edited 07-15-2010 10:52 AM
How does one become a regex ninja? Practice. Here is a VI I use for testing regexes.
All my regexes live in Texas....
07-15-2010 11:17 AM
Thanks for sharing Darin.
That's a nifty little tool. I like the fact that it highlights what the regular expression matches. That's make it a whole lot easier to debug the expression.
07-15-2010 12:04 PM
jcarmody wrote:
[...] I'll explain the regular expressions I used during my lunch hour.
This is my final attempt:
16 {1}|[0-9]1 6|1 *[\w\d]{6}\s.*: *6
There are three parts to this regexp, the "|" (pipe) separates them and is an OR operator.
The first part is: 16 {1}
This looks for a literal "16" followed by only one space. The prevents the line number or
something in the last column from matching.
The second part is: 1 6
This looks for a literal "1 6"
The last part is: 1 *[\w\d]{6}\s.*: *6
This finds the instances where there is a 1 at the end of one line and a 6 at the beginning
of the next. The expression begins and ends with a 1 and 6, it's the stuff in between
that makes this work.
<space>* looks for zero or more spaces
[\w\d] looks for any alpha-numeric character
{6} looks for exactly six of them
\s looks for whitespace, it'll catch the line-feed, new line or carriage return
.*: matches the line number, spaces and colon
<space>* gets zero or more spaces
Darin.K, thanks for your help again. I've put your regexp tester into my /project folder. I learned to use variants this way from your post here.