LAVA 1.0 Content Posted March 13, 2007 Report Share Posted March 13, 2007 Since people were kind enough to help crelf with his homework, I thought I would ask for some help too... I'm working with the ATML specification XML schema for Test Results. There is a simpleType definition called StandardUnits that includes a regexp for qualifying a string. I cut and paste the regexp string into a LabVIEW VI and tried to use it, but got an error: There is an unmatched parenthesis in a regular expression. Can you help me find it, PLEASE?!!! The regexp does have a comment saying it hasn't been exhaustively tested see my attached image and vi. http://forums.lavag.org/index.php?act=attach&type=post&id=5186 http://forums.lavag.org/index.php?act=attach&type=post&id=5185 But SERIOUSLY, has anyone ever seen a regexp string like this?!! Quote Link to comment
crelf Posted March 13, 2007 Report Share Posted March 13, 2007 QUOTE(LV Punk @ Mar 13 2007, 01:21 AM) Since people were kind enough to http://forums.lavag.org/index.php?showtopic=6702&pid=25861&mode=threaded&start=0#entry25861' target="_blank">help crelf with his homework, I thought I would ask for some help too... Quote Link to comment
Mike Ashe Posted March 13, 2007 Report Share Posted March 13, 2007 QUOTE(LV Punk @ Mar 12 2007, 10:21 AM) I'm working with the http://grouper.ieee.org/groups/scc20/tii/' target="_blank">ATML specification XML schema for Test Results. There is a simpleType definition called StandardUnits that includes a regexp for qualifying a string. I cut and paste the regexp string into a LabVIEW VI and tried to use it, but got an error: There is an unmatched parenthesis in a regular expression. Can you help me find it, PLEASE?!!! But SERIOUSLY, has anyone ever seen a regexp string like this?!! Yeah, I've seen it before, at the same place you did. I started looking at ATML for test exec purposes a little over a year ago and decided that it wasn't ready for prime time, at least not my prime time as it was not a paying project. A lot of ATML is DoD driven, hence .... As for finding the problem: 1. Run the string through a shift register in a loop indexing each successive character, looking for ( and ). 2. Start a counter at 0 and for each ( do a +1 and for each ) do a -1 and add the index location to an array for each. If your counter goes negative, then you just had an unmatched ) and you can look in your indexes for pairs of () to try to locate the mismatch. 3. Reverse the string and then repeat the above, now if you go negative you'll have an unmatched ( and again you can check the pairs to try to locate. Good luck PS: wouldn't it be great if the error message had the index of the unmatched parentheses? Too much to ask? Or at least whether it was an open or close parentheses to look for? Quote Link to comment
eaolson Posted March 13, 2007 Report Share Posted March 13, 2007 QUOTE(LV Punk @ Mar 12 2007, 10:21 AM) But SERIOUSLY, has anyone ever seen a regexp string like this?!! That's the sort of thing that can make you wake up screaming. The error seems to be in the "G[b|i]" part of the string. If I take that out, the error goes away. I assume it's supposed to be "G(b|i)"? Quote Link to comment
LAVA 1.0 Content Posted March 13, 2007 Author Report Share Posted March 13, 2007 My (god|goodness|heavens)! You ARE TOO detail oriented! BTW, Thanks :thumbup: Quote Link to comment
eaolson Posted March 13, 2007 Report Share Posted March 13, 2007 QUOTE(LV Punk @ Mar 12 2007, 01:55 PM) BTW, Thanks :thumbup: You're welcome. Actually, I just saw it as an opportunity to sharpen my regexp skills, which aren't as polished as I'd like them to be. This error seems to have something to do with nesting an [] inside an () inside an []. When I take away any one of those elements, I stop getting the error. Now, is this a malformed regexp, or is it a problem with LabVIEW? (Told you my regexp skills weren't as polished as I'd like them to be.) Quote Link to comment
Yair Posted March 13, 2007 Report Share Posted March 13, 2007 QUOTE(LV Punk @ Mar 12 2007, 05:21 PM) But SERIOUSLY, has anyone ever seen a regexp string like this?!! No, but it reminds me of the saying that PERL looks like an explosion in an ASCII factory. Quote Link to comment
ned Posted March 14, 2007 Report Share Posted March 14, 2007 QUOTE(LV Punk @ Mar 12 2007, 10:21 AM) But SERIOUSLY, has anyone ever seen a regexp string like this?!! There's http://www.ex-parrot.com/pdw/Mail-RFC822-Address.html' target="_blank">this one for validating an email address. Quote Link to comment
Michael Aivaliotis Posted March 14, 2007 Report Share Posted March 14, 2007 For a moment there i thought I was looking at an autostereogram. Quote Link to comment
Jim Kring Posted March 14, 2007 Report Share Posted March 14, 2007 There are a variety of software applications (and some are free) for building & testing regular expressions that can quickly identify syntax and other problems. Try googling "regular expression software". Cheers, Quote Link to comment
eaolson Posted March 14, 2007 Report Share Posted March 14, 2007 Just to make sure this horse really is dead ... I was thinking the error being thrown was incorrect, and so brought this up over at the NI forums. I was wrong; the regexp is just malformed. I think the "G[b|i]" element should really be "G(b|i)" and the outermost [ and ] should be ( and ). You can't next square brackets or use parentheses inside square brackets. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.