ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

REGex Issue

Solved!
Go to solution

Hello,

Got stuck with Regex, may be some guidance could work.

*****************************************

LSBERT\sCHPAR\s1\sSTAT\r\nSTAT=NoDMSCheck\r\n>\s

***************************************

is the text and I need to start from Right to Left - 

a) Have to exclude ">" and then only take the middle Line "STAT=NoDMSCheck"

 

The issues is the number of lines can change(2,3,4) and the text within those lines.

The only two consistent factors are  

a. ">" at the end

b. I only take the second last line that is where my focus is.

Tried many Regex combinations bit looks like have lost my edge.

 

Thanks in advance.

Best,

Akshay

0 Kudos
Message 1 of 4
(1,608 Views)
Solution
Accepted by topic author aparab

Maybe using a positive lookahead for that > like

 

.*(?=\r\n>)

 

That seemed to look for really simple test cases at least.

Matt J | National Instruments | CLA
0 Kudos
Message 2 of 4
(1,589 Views)

There may be different approaches, even without Regex.

For example (if I understood your needs), you can use Spreadsheet String to Array with %s as format: you get a 2D string array, extract the first column and check if the the last element is >\s. If yes, take the second last element.

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 3 of 4
(1,585 Views)

thanks  Jacobson, 

that solves 
I had a solution "(?<=\n)\\*[^\n\r]*" but yours elegant.

0 Kudos
Message 4 of 4
(1,577 Views)