LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

regular expression : how to find 2 strings in a line (and/ or)

Hi all,

 

what can be a regular expression to search for 2 strings in a line. 

 

ex:  corner_fff_dev_26_temp_25_lane_00_vdd_0.95_mode_2.5G.csv

 

can i be able to search by these 2 combinations. the line changes all the time so just by giving any 2 or multiple parameters by and/or.

 

1.(temp & mode) 

2.(temp or more)

 

Thanks in advance

0 Kudos
Message 1 of 8
(4,725 Views)

I am not very clear. Can you tell us the output you want from the line corner_fff_dev_26_temp_25_lane_00_vdd_0.95_mode_2.5G.csv

 

?

0 Kudos
Message 2 of 8
(4,722 Views)

You can look for one OR the other by using a "|" (pipe); AND is implied.

regexpOR.png

 

Edit: the snippet was made with the Code Capture Tool in LabVIEW 8.6.

Message Edited by jcarmody on 12-01-2009 06:00 AM
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 3 of 8
(4,710 Views)

Thanks jim,

 

if i do (mode.*temp) , returns nothing.

 

the line which i gave here changes all the time so temp and mode might not be sequential,

so something like google search, you put in keywords and search for them ( match any letter or word or symbol)

 

is it possible?

0 Kudos
Message 4 of 8
(4,684 Views)

freemason wrote:

Thanks jim,

 

if i do (mode.*temp) , returns nothing.

 

the line which i gave here changes all the time so temp and mode might not be sequential,

so something like google search, you put in keywords and search for them ( match any letter or word or symbol)

 

is it possible?


Try (mode.*temp)|(temp.*mode)

0 Kudos
Message 5 of 8
(4,668 Views)

Alternatively, if you want to make sure you get the numbers/letters after the item, try (mode.*temp[_][0-9]*)|(temp.*mode[_][0-9]*[.]*[0-9]*[A-Z]*)

(allows for both integer and non integers proceding letter in mode, and any number of letters (capitals only), and any length temperature (not negative)
Message Edited by Hornless.Rhino on 02-12-2009 10:11 AM
0 Kudos
Message 6 of 8
(4,658 Views)

freemason wrote:

if i do (mode.*temp) , returns nothing.


The regular expression breaks down like this:

  • "mode" looks for the literal string "mode"
  • "." looks for anything (wildcard)
  • "*" repeats the previous character as many times as possible (greedy)
  • "temp" looks for the literal string "temp"

 

So, "mode.*temp" will look in the string for "mode" with any number of any characters followed by the string "temp".  You'll have to configure your search based on what you want to get.  I use this site for regexp help.

 

You might be better off using two searches rather than trying to make one search for everything.  This example will only work for mode if it's at the end of the input string.  If I knew the exact format I could suggest a regexp that would catch it anywhere.

 

snippet_BD.png

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 7 of 8
(4,641 Views)

Thanks all,

 

thanks jcarmody, the regexp help site is very useful

0 Kudos
Message 8 of 8
(4,599 Views)