02-23-2012 01:48 PM
Another Search i need to implement in my program.
Example
$GPGSV,3,1,09,01,28,064,41,04,08,182,32,07,19,136,38,08,54,127,47*76
$GPGSV,3,2,09,11,17,049,38,15,20,300,39,17,78,238,49,27,20,318,39,*74
$GPGSV,3,3,09,28,60,016,47,,,,,,,,,,,,*48
The first digit is a 3. That tells you there are 3 sentence. So may need a loop that would first search for the sentences. it may be (1,2, or 3). Ex. if there is 2 sentences i would need to search sentence 1 and sentence 2 and extract the number after the 3 digit number.
I need to extract the value after the 3 digit for all 3 sentences that are randomly generated. for example after the 064 i need 41 .
In this example there are 3 sentence but not in all cases. It may have 1-3 sentences at any time.
i need them to be placed into an array in this case there is only 9 values but they may be as much as 12.
41
32
38
47
38
39
49
39
47
02-23-2012 01:50 PM
As im programming it i understand a lil more becuase of your explanation but each time i run the program i have to tweak it a little but and need to implement few other parts of the program. but im getting a little stuck.
02-23-2012 02:34 PM
Now you're getting into territory where Regular Expressions make life easier, or impossibly obfuscated depending on your point of view. I'm a fan of regexes, especially when I can use a submatch. This example finds every group of 2 digits that follow thre digits and a comma. The loop lets me find all of them without knowing how many there are to begin with, so I don't need to consider how many "sentences" there are.
That regular expression reads like this:
What this means is that the node will find the first pattern of three digits, a comma and two digits; and return the two digits. The Match Regular Expression node is expandable at the bottom to expose terminals for any submatches you define in your regex.
My favorite resource for learning about Regular Expressions is here. It's not critical that you learn how to use them, but it'll make your LabVIEW-fu quite formidable.
02-23-2012 04:11 PM
jcarmody
Thanks for your help once again. and appreciate you breaking it down so i can fully understand what it is your doing!
02-23-2012 08:20 PM
@*E* wrote:
jcarmody
Thanks for your help once again. and appreciate you breaking it down so i can fully understand what it is your doing!
E-
Up on the forums we say "thank You" by hitting the "Kudos" button. Its been fun watching Jim teach regexes again. (Often, he amazes us all!) Kudos !
Jim- that is just sick! you should change you signature line to a regex that matches any Alias on the forums ranked "Actiive Participant" or more active. (Not a challenge- I believe you know that regex) Bows
02-24-2012 05:14 AM
Is my example visible lost in your browser, too? I can't see it.
02-24-2012 12:44 PM
I can see it.
02-25-2012 04:53 PM
jcarmody
can you please tell me what syntax do I use to search for the decimal numbers and extract the number with out the M. i followed your earlier example and was able to extract the
2.5
M
1.3
M
2.1
M*38
Then i had to parse out starting beginning at 2.5 then 3 characters after. The problem with this is I'm not sure if in all cases the numbers would be 2.5 or if it may just be 2. Also I didn't want to have it Read the M's. The reason being it may be 3 decimal numbers or it may have a case were they are 2 numbers so if I hard code it in some cases the M will be showing in my indicator.
example#1
04,05,08,,,,,,2.5,M,1.3,M,2.1,M,*38
2.5
1.3
2.1
example #2
04,05,08,09,10,11,,,,,,1.3,M,2.1,M,*38
1.3
2.1
02-27-2012 05:10 AM
02-27-2012 06:13 AM
Thanks jcarmody!