BreakPoint

cancel
Showing results for 
Search instead for 
Did you mean: 

Regular Expressions Board

I got the first portion working by using the following regex:

 

SEP_OF_ME_IS_A_CONFIG_TABLE\#\#\n(.*) :ab50_34_cdef

 

followed by the first part of the example you provided.  Still elegant. Thank you.

 

I know the above expression looks for the data in between both strings, but I also have access to the string that immediately follows the match.

 

Now onto the 2nd portion.

Message 51 of 150
(9,366 Views)

You have to be careful with wild card s in regular expressions. You can get greedy matches with may result in the wrong match. This is the reason I try to bracket the data for the specific search I am doing. A greedy match can be grabbing LOTS more stuff than you may think.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 52 of 150
(9,362 Views)

Anyone up for validating a regex for me? I'm trying to match any filename that does not begin with a tilde (~) and has a filetype of .xls or .xlsm. Here's the regex I've got so far: ^[^\~].*\.(xls|xlsm)$

 

It seems to work against most the test vectors I can come up with (+1 for VI Tester!), but I'm not experienced enough with regexes to see any lurking "gotcha".

 

Here's how I read that regex: Make sure that the first character anchored to the beginning of the string is not a literal tilde, and then match any and all characters up until requiring a literal dot followed by either xls or xlsm anchored to the end of the string.

 

ExcelFileRegex.png

Message 53 of 150
(9,308 Views)

You can write it slightly more compactly as:

where the question mark signifies 0 or 1 instances of the previous token, which in this case is the letter "m".

 

Can't see any gotchas in that.

Message 54 of 150
(9,279 Views)

I found this guide really helpful http://www.regular-expressions.info/reference.html

 

Specifically, the "*? (lazy star)" explanation. It was not covered in the NI documentation.

Message 55 of 150
(9,239 Views)

@jcarmody wrote:

I answered this question:


@emyh wrote:

 

[...] have: C1-C10

(C1-C10 means there are actually ten cmponents; C1, C2, C3...C10)

I now want to convert the array containing C1-C10 into an array looking like this:

 

C1

C2

C3

.

.

.

C10

 

[...]


... with this Regexp:

 

Example_VI.png

 

Read the Regexp like:

 

  • ([A-Z]) find an upper case alpha-character and store it in a backreference
  • ([0-9]+)find one or more digits and store it, too, in a backreference
  • -find a "-"
  • (\1)find what was found in the first backreference.  In this example it will find a "C" at the beginning and search again for a "C"
  • ([0-9]+)find another one or more digits and store it in a backreference
I'm only using one of the backreferences, but the others are so I can expand the node and get at each of them (in order of appearance in the regexp).

 


Would there be a regEx that could do the following string without a loop?

 

\t00\t01\t02\t03\t04\t05\t06\t07\t08\t09\t0A\t0B\t0C\t0D\t0E\t0F

Message 56 of 150
(9,167 Views)

Here is the brute force variation which will work for upto 16 numbers and a more generalized variation that uses a loop.

Match Hex Numbers.png



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 57 of 150
(9,159 Views)

LOL!!

 

Sometimes it is simply better to use the basic method and type the whole thing in...

which is:

 

"\t00\t01\t02\t03\t04\t05\t06\t07\t08\t09\t0A\t0B\t0C\t0D\t0E\t0F"

 

😉

 

Thanks for the example.  It may come in handy in the future.

 

yagattalovethisthread

Message 58 of 150
(9,150 Views)

A forum member posted a request to extract the data value pairs from an input string which looked like the following: { "Address" : "0xC800A8C0", "Channel" : 0, "Descrip" : "DDNS", "Event" : "Update", "SerialID" : "000b3d016ce3", "StartTime" : "2011-12-01 20:04:51", "Status" : "Start", "Type" : "Log" }.

 

Here was the solution I suggested using regular expressions.

 

DB Parser.png

 

Note: The regular expression could be modified so the quotes were not escaped. I added the '\' (to escape the quote) initially as a "just in case" measure.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 59 of 150
(9,114 Views)

prepping a question concerning two strings:

 

 

freqNone\s\s\s\s\s\s\s\s\s\s\s\setsi18_a_28\s\s\s\s\s\s\s\s\setsi23_a_56\s\s\s\s\s\s\s\s\sfcc23_c_50\s\s\s\s\s\s\s\s\s\r\netsi13_a_28\s\s\s\s\s\s\s\s\setsi18_a_56\s\s\s\s\s\s\s\s\sfcc23_c_30\s\s\s\s\s\s\s\s\s\setsi28_c_28\s\s\s\s\s\s\s\s\r\netsi13_a_56\s\s\s\s\s\s\s\s\setsi23_a_28\s\s\s\s\s\s\s\s\sfcc23_c_40\s\s\s\s\s\s\s\s\s\setsi28_c_56\s\s\s\s\s\s\s\s

 

 

freqNone\s\s\s\s\s\s\s\s\s\s\s\suk6L_1_56_R5\s\s\s\s\s\s\s\setsi13_1_28_R5\s\s\s\s\s\sfcc18_1_50_R5\s\s\s\s\s\s\r\nfcc6L_1_10_R5\s\s\s\s\s\s\sfcc11_1_30_R5\s\s\s\s\s\s\setsi13_1_56_R5\s\s\s\s\s\sfcc23_1_30_R5\s\s\s\s\s\s\r\nfcc6L_1_30_R5\s\s\s\s\s\s\sfcc11_1_40_R5\s\s\s\s\s\s\setsi13_2_28_R5\s\s\s\s\s\sfcc23_1_40_R5\s\s\s\s\s\s\r\nic6L_1_29p65_R5\s\s\s\s\sfcc11_2_30_R5\s\s\s\s\s\s\siraq15_2_56_R5\s\s\s\s\s\sfcc23_1_50_R5\s\s\s\s\s\s\r\nic6L_1_30_R5\s\s\s\s\s\s\s\sfcc11_2_40_R5\s\s\s\s\s\s\setsi18_2_28_R5\s\s\s\s\s\sfcc23_2_50_R5\s\s\s\s\s\s\r\nitu6L_1_60_R5\s\s\s\s\s\s\sukr11_2_28_R5\s\s\s\s\s\s\setsi18_2_56_R5\s\s\s\s\s\sfcc23_3_40_R5\s\s\s\s\s\s\r\nmain6L_1_29p65_R5\s\s\sesp13_1_28_R5\s\s\s\s\s\s\setsi18_3_28_R5\s\s\s\s\s\sfcc23_3_50_R5\s\s\s\s\s\s\r\nrus6L_1_28_R5\s\s\s\s\s\s\sesp13_1_56_R5\s\s\s\s\s\s\setsi18_3_56_R5\s\s\s\s\s\situ23_2_56_R5\s\s\s\s\s\s

 

 

 

freqNone            etsi18_a_28         etsi23_a_56         fcc23_c_50         
etsi13_a_28         etsi18_a_56         fcc23_c_30          etsi28_c_28        
etsi13_a_56         etsi23_a_28         fcc23_c_40          etsi28_c_56       

 

 

freqNone            uk6L_1_56_R5        etsi13_1_28_R5      fcc18_1_50_R5      
fcc6L_1_10_R5       fcc11_1_30_R5       etsi13_1_56_R5      fcc23_1_30_R5      
fcc6L_1_30_R5       fcc11_1_40_R5       etsi13_2_28_R5      fcc23_1_40_R5      
ic6L_1_29p65_R5     fcc11_2_30_R5       iraq15_2_56_R5      fcc23_1_50_R5      
ic6L_1_30_R5        fcc11_2_40_R5       etsi18_2_28_R5      fcc23_2_50_R5      
itu6L_1_60_R5       ukr11_2_28_R5       etsi18_2_56_R5      fcc23_3_40_R5      
main6L_1_29p65_R5   esp13_1_28_R5       etsi18_3_28_R5      fcc23_3_50_R5      
rus6L_1_28_R5       esp13_1_56_R5       etsi18_3_56_R5      itu23_2_56_R5     

 

 

 

(I gatta go but will be back with the actual question!)

Message 60 of 150
(9,082 Views)