dannyt Posted February 14, 2007 Report Share Posted February 14, 2007 Hi, I wonder if anyone could help please help me improve my labview with regard regular expressions. I am checking serial / part numbers entered on a front panel by operator; when the operator presses enter I do a little check to see if a valid part number has been entred. This is currently implemented and working I am using a matchsub-string vi but the pattern match is far to general and I would like to tighten it. For example I would like to match MTY2345 MAF2345 PTC2345 CVS2345 in perl or python there is a | (pipe) option that can be used so (MTY | MAF | PTC | CVS )2345 would work fine, it appears there is no pipe in the labview regular expressions. I can see a way to implement this using multiple matchsub-string vi's each using the output of the previous one, but I feel if only i could get the correct pattern I could do it with only one matchsub-string vi. I am using Labview version 7.0 cheers in advance dannyt Quote Link to comment
Tomi Maila Posted February 14, 2007 Report Share Posted February 14, 2007 I think it was LV 8.0 that came with new regexp node that works in a very similar way as Perl regexps. Could you consider upgrading to newer LV? Tomi Quote Link to comment
dannyt Posted February 14, 2007 Author Report Share Posted February 14, 2007 QUOTE(Tomi Maila @ Feb 13 2007, 12:02 PM) I think it was LV 8.0 that came with new regexp node that works in a very similar way as Perl regexps. Could you consider upgrading to newer LV?Tomi ah Labview 8.0 or even better 8.2, I am trying to go in that direction, but you know the old Newtonian law on Software Inertia... a software version bought and paid for should remain in rest until senior management say otherwise As I said I can implement it in 7.0, I was just hoping somebody would tell me I was wrong and there was a way to match it with one single MatchPattern vi if only i got the pattern right. Quote Link to comment
Mellroth Posted February 14, 2007 Report Share Posted February 14, 2007 QUOTE(dannyt @ Feb 13 2007, 01:19 PM) ah Labview 8.0 or even better 8.2, I am trying to go in that direction, but you know the old Newtonian law on Software Inertia... a software version bought and paid for should remain in rest until senior management say otherwise As I said I can implement it in 7.0, I was just hoping somebody would tell me I was wrong and there was a way to match it with one single MatchPattern vi if only i got the pattern right. Can you tell us a bit more what kind of expressions you want to match? Is it always a character sequence followed by numbers etc.? If it is then you could check out the "Match First String" primitive. QUOTE Compares each string in string array with the beginning of string until it encounters a match. /J Quote Link to comment
dannyt Posted February 14, 2007 Author Report Share Posted February 14, 2007 QUOTE(JFM @ Feb 13 2007, 12:27 PM) Can you tell us a bit more what kind of expressions you want to match? Is it always a character sequence followed by numbers etc.?If it is then you could check out the "Match First String" primitive. /J JFM, Thanks :thumbup: for the Match First String suggestion, that's a nice way of doing this, I had not used this before. Examples are MTY2345 MAF2345 PTC2345 CVS2345 as you say I can use the match first string to match MTY MAF PTC and CVS build into an array and then just check the number at the end, this is a great deal nicer than what I was planning to do. cheers danny Quote Link to comment
LAVA 1.0 Content Posted February 14, 2007 Report Share Posted February 14, 2007 QUOTE(dannyt @ Feb 13 2007, 12:30 PM) Hi, I wonder if anyone could help please help me improve my labview with regard regular expressions. I am checking serial / part numbers entered on a front panel by operator; when the operator presses enter I do a little check to see if a valid part number has been entred. This is currently implemented and working I am using a matchsub-string vi but the pattern match is far to general and I would like to tighten it. For example I would like to match MTY2345 MAF2345 PTC2345 CVS2345 in perl or python there is a | (pipe) option that can be used so (MTY | MAF | PTC | CVS )2345 would work fine, it appears there is no pipe in the labview regular expressions. I can see a way to implement this using multiple matchsub-string vi's each using the output of the previous one, but I feel if only i could get the correct pattern I could do it with only one matchsub-string vi. I am using Labview version 7.0 cheers in advance dannyt why don't you use the vi find regular expresion (under String) Then you can enter your regualr expresion: (MTY|MAF|PTC|CVS)2345 But without blanks... (I hope that this vi is also in LV7, I use LV8.2...) Quote Link to comment
gb119 Posted February 14, 2007 Report Share Posted February 14, 2007 QUOTE(dannyt @ Feb 13 2007, 11:30 AM) Hi, I wonder if anyone could help please help me improve my labview with regard regular expressions. [...] I can see a way to implement this using multiple matchsub-string vi's each using the output of the previous one, but I feel if only i could get the correct pattern I could do it with only one matchsub-string vi. I am using Labview version 7.0 Many years ago (well about 6) I wrote a vi that interfaced to the Perl Compatible Regular Expressions library for LabVIEW 5.1. It's downloadable from: http://www.crojack.org/labview/pcre-2.08-lv.zip If you're running Windows then there is a precompiled binary, otherwise it's a question of compiling the CIN and linking to a version of libpcre. Basicallly my routine does the same as the one now builtin in LV 8.0+ - except that I did it first and mine isn't a nice extending node but can handle variable numbers of sub-patterns at run time. It's a long time since I used that version (I rolled the CIN code into a custom dll full of other useful code functions, and the PCRE version is positively prehistoric in internet terms !) so I can't promise that it all still works.... Quote Link to comment
robijn Posted February 14, 2007 Report Share Posted February 14, 2007 QUOTE(dannyt @ Feb 13 2007, 02:02 PM) Examples are MTY2345 MAF2345 PTC2345 CVS2345 With the "old" LV regex you could match on [a-zA-Z]+ and then the alpha part is in the Match output and the numeric part is in the Remaining output. Joris Quote Link to comment
tomstickland Posted February 15, 2007 Report Share Posted February 15, 2007 I'd set an array of acceptable patterns and a for loop with a "match reg expression" search function in it, with a boolean shift register and an OR gate. Quote Link to comment
dannyt Posted February 16, 2007 Author Report Share Posted February 16, 2007 Thanks to everyone for the replies..... for now I will use the 'Match First String' solution, I like that. But I have an evaluation copy of Labview 8.2 and oh the Match Regular expression function is sooo nice :thumbup: , there are so many places in our code where this would simplify life cheers dannyt 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.