LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

match pattern numbers and strings

Hello,

 

I am trying to use match pattern to read numbers and strings from a file. I can't seem to figure out how to allow the function to read the strings. For example, if the file contains the following:

 

1.1 2.1 3.1 Cat DOG

 

I would think that [.]?[0-9]+[.]?[0-9]*[Cat][DOG] would do the trick. Any pointers?

 

Thanks,

Micah

0 Kudos
Message 1 of 6
(3,879 Views)

Match Pattern isn't as powerful as Match Regular Expression, and some of what you're trying to do requires that power.

 

Example_VI.png

 

I changed your regexp a little by escaping the decimal points, grouping/repeating the number search and making literals out of "Cat DOG".  We'd need a better description, or a more representative sample, of your expected data to do more.

 

([\.]?[0-9]+[\.]?[0-9]* )*[\w\s]*

 

 

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

0 Kudos
Message 2 of 6
(3,856 Views)

Example_VI.png

0 Kudos
Message 3 of 6
(3,854 Views)

When I use this syntax for the regular expression input, my code only picks out the string and does not read the numbes. To expand a bit on my projet, the file I am reading in has 12 columns but I only care about the 1st, 9th, and 11th columns. The problem I am having is columns 10 and 12 are the strings (indicating fault degredation modes in a test bed). I simply want my code to read in all the columns and then I'll process the data that I need. 

 

Thanks,

Micah

0 Kudos
Message 4 of 6
(3,827 Views)

@apok wrote:

Example_VI.png


This is not a solution, %s will match any string not only Cat and DOG and if the input string do not match the format string it will generate an error.

 

Ben64

0 Kudos
Message 5 of 6
(3,826 Views)

@Micah59 wrote:

[...] the file I am reading in has 12 columns but I only care about the 1st, 9th, and 11th columns. The problem I am having is columns 10 and 12 are the strings (indicating fault degredation modes in a test bed). I simply want my code to read in all the columns and then I'll process the data that I need. 

 

Thanks,

Micah


If the data is always deliminated by spaces, you can use Spreadsheet String to Array:

 

Example_VI.png

 

If you need to do anything with the fault strings, you can replace the Double constant (in the array constant) with a String and convert whichever numbers you need from the resulting array of Strings.

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

0 Kudos
Message 6 of 6
(3,803 Views)