LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Scan string

Solved!
Go to solution

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

0 Kudos
Message 21 of 30
(1,665 Views)

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.

0 Kudos
Message 22 of 30
(1,666 Views)

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.

 

Example_VI.png

 

That regular expression reads like this:

  • [\d] find any digit
  • {3} exactly three of them
  • , find a comma
  • ( begin a submatch
    • [\d] find any digit
    • {2} exactly two of them
  • ) end the submatch

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.

 

Spoiler

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.

 

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

Message 23 of 30
(1,655 Views)

jcarmody

Thanks for your help once again. and appreciate you breaking it down so i can fully understand what it is your doing!

0 Kudos
Message 24 of 30
(1,644 Views)

@*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


"Should be" isn't "Is" -Jay
Message 25 of 30
(1,636 Views)

Is my example visible lost in your browser, too?  I can't see it.

 

 

Spoiler
I only ask because I don't save my snippets; I rely on the forum.

 

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

Message 26 of 30
(1,618 Views)

I can see it.

--
Tim Elsey
Certified LabVIEW Architect
Message 27 of 30
(1,589 Views)

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

0 Kudos
Message 28 of 30
(1,565 Views)

([\d]*\.[\d]*),M

 

This will return any float number that is immediately followed by ",M"

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

Message 29 of 30
(1,536 Views)

Thanks jcarmody!

0 Kudos
Message 30 of 30
(1,525 Views)