09-25-2008 09:27 AM - edited 09-25-2008 09:34 AM
I am trying to build a regular expression that will search the following array of strings for the sequence 3.1
Read Modem Information:
Device Type .......................... 2
Serial Number ........................ 11437
Primary Phone Number ................. 1800...
Secondary Phone Number ............... 1800...
Modem Software ....................... BOOT.3.1 Jun 17 2004 17:02:26
Bracelet Software .................... 4.0
Validation Number .................... Default
Login Name ........................... Default
Login Password ....................... Default
Case Number .......................... Default
Primary Encryption Key ............... Default
Secondary Encryption Key ............. Default
Dialing Format ....................... True
Call In Format ....................... True
Modem Download Flag is Clear ......... True
SCRAM Download Flag is Clear ......... True
SCRAM Char Table Load Flag is Clear .. True
Download Inhibit ..................... True
Exiting Boot (8 sec) ................. Switching to operating memory.
Main Revision ........................ SLCP.3.1 Jun 17 2004 17:02:46
Reset ................................ Complete
This is my first real foray into regular expressions and so I am lost trying to understand the help file.
Thanks!
Tay
09-25-2008 09:59 AM - edited 09-25-2008 10:00 AM
09-25-2008 10:06 AM
That would match the line with "Modem Software" and "Main Revision".
Which 3.1 are you looking for? Are you trying to find a specific line?
09-25-2008 10:18 AM
09-25-2008 10:22 AM - edited 09-25-2008 10:24 AM
I am actually trying to capture both. I'm using the 'Match Regular expression' vi since the line length may vary on occasion and the value may not always be 3.1
Tay
09-25-2008 10:27 AM
Not sure what you mean by the line length may vary, requiring using the "match regular expression". Which string may change? The lengths of the input strings are varying, and the
"regular expression" while a fixed constant in my example could be a control.
09-25-2008 10:36 AM
I think the OP was puzzled about how to form a RE.
For the specific case or how to find the exact string "3.1", and to not match anything else, the RE is "3\.1"
Why?
For the most part, a RE search string is an exact character match. However things change when certain "special characters" are included in the search string. The RE help message says what they are, but the descriptions can be a bit daunting at first.
As a first example of special characters, the RE of "." (The single character fullstop) will match ANY single character. Thus a RE of "3.1" will match "3.1", "301", "3Z1", but not "31" or 3aa1".
Another special character is "*". It modifies the match to allow zero or more of the preceeding bit. So "3.*1" matches "3", followed by any number of any character (including no characters), followed by "1". so it will match "31", "301", "3ABC51", "31111111"
The action of a special character is cancelled by preceeding it with a backslash. So in the example above "3\.1" matches ONLY the string "3.1"
The best way to discover exactly how RE's work is to try some out. Make a VI containing Match Pattern, and suitable controls and indicators. Work through the examples and see how they operate. Now try your own!
09-25-2008 10:40 AM
09-25-2008 11:18 AM
Ok, got it. Here's what I did. And I needed to capture three instances of numbers seperated by a period. One of them isn't 3.1.
Yes, what I needed help with was formulating the regular expression.
Thanks to all!
Tay
09-26-2008 04:10 AM