jbabb Posted September 28, 2009 Report Share Posted September 28, 2009 (edited) Hello, I'm trying to parse a version number of format 00.00.00.00 from some telnet traffic. I get several lines of output from telnet when I send it a "version" command. I'm using the match pattern function on the returned lines and among the regex-es I used are: \d\d\.d\d\.d\d\.d\d\ m/([0-9]{2}.){3}[0-9]{2}/ and variants of these, as well as other regex-es. I always get the version string plus the several lines afterward. as though the regex is being ignored. Is there anything about how LV implements regex that quirky , or some issue I should know about? Thanks! J Edited September 28, 2009 by jbabb Quote Link to comment
Mark Yedinak Posted September 28, 2009 Report Share Posted September 28, 2009 Hello, I'm trying to parse a version number of format 00.00.00.00 from some telnet traffic. I get several lines of output from telnet when I send it a "version" command. I'm using the match pattern function on the returned lines and among the regex-es I used are: \d\d\.d\d\.d\d\.d\d\ m/[0-9].{3}[0-9]/ and variants of these, as well as other regex-es. I always get the version string plus the several lines afterward. as though the regex is being ignored. Is there anything about how LV implements regex that quirky , or some issue I should know about? Thanks! J Can you post more of the surrounding data? Also, are you simply trying to extract the version string out of the data? Quote Link to comment
jbabb Posted September 28, 2009 Author Report Share Posted September 28, 2009 Here's my code... Quote Link to comment
jcarmody Posted September 28, 2009 Report Share Posted September 28, 2009 Is there anything about how LV implements regex that quirky , or some issue I should know about? I don't have LabVIEW at home so I can't test anything, but there's a comment in the help for Match Regular Expression that says: The Match Regular Expression function gives you more options for matching strings but performs more slowly than the Match Pattern function. I've had trouble using Match Pattern and fixed the problems by using Match Regular Expression. I'm also thinking that \d\d\.d\d\.d\d\.d\d\ should be \d\d\.\d\d\.\d\d\.\d\d instead and that m/[0-9].{3}[0-9]/ might be better as ([0-9]\.[0-9]){3}. I sure wish I could test this in LabVIEW... Quote Link to comment
Mark Yedinak Posted September 28, 2009 Report Share Posted September 28, 2009 The following regular expression will extract a version string from the text: [0-9]{2}\.[0-9]{2}\.[0-9]{2}\.[0-9]{2} Here is a condensed version of the regular expression: ([0-9]{2}\.){3}[0-9]{2} It is not clear from your code exactly what you are trying to accomplish though. Screen shot of the code. Quote Link to comment
jbabb Posted September 28, 2009 Author Report Share Posted September 28, 2009 Hello, Thanks very much to all for your suggestions . And yes Mark Y., I am trying to just extract the version string. I will start trying them out now. J Quote Link to comment
jbabb Posted September 29, 2009 Author Report Share Posted September 29, 2009 Hello and THANKS to all . That was it! I used the regular expression match and one of the patterns posted as well, and it worked the FIRST time. Thanks! Jeff Quote Link to comment
asbo Posted September 29, 2009 Report Share Posted September 29, 2009 As jcarmody pointed out, you didn't properly escape your regex - "d" is a the digit group and needs to be proceeded with a backslash. Likewise, a period is a single wildcard character and must be escaped if you're actually looking for a literal period. 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.