Jump to content

regexp problem - do my homework please...


Recommended Posts

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 :rolleyes:

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?!!

Link to comment

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?

Link to comment

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)"?

Link to comment

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.)

Link to comment

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.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.