LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

ragular expression - Risultato errato

Ciao a tutti,

 

premetto che é la prima volta che scrivo in questo forum, nel caso infrangessi qualche regola vi prego di farmelo notare

 

sto usando il la funzione "Search Replace" in modalitá "Regular Expression" per verificare che una stringa in ingresso abbia il giusto formato.

 

La stringa in questione é la seguente

 

"[Points]"

 

con le reg ex "^\d+\.\d+(E[+-]\d+)* \s+\d+\.\d+(E[+-]\d+)*" voglio verificare che le stringe siano nel formato

"5.00000000000000E-0001  4.29787368774414E+0001 07.03.2013 11:28:04"

(Trovate in allegato il codice che sto usando con il relativo debug)

 

in teoria avendo in ingresso la stringa "[Points]", la reg ex non dovrebbe avere alcun match, invece la funzione im ritorna "s"

ho verificato che dipende dal fatto che ho usato "\s+" nella reg ex, ma "\s" dovrebbe significare uno spazio, non la lettera "s"

 

 

sono io che ho capito male il funzionamento delle reg ex, o labview sbaglia la comparazione?

 

Grazie a tutti

 

 

0 Kudos
Message 1 of 6
(2,356 Views)

Hi summerwind,

 

while I respect all those familiar with RegEx I would prefer that approach to parse the string:

check.png

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 6
(2,348 Views)

Thanks for answering

 

this is not what I am looking for

 

if I have "[Points]" as input string, your solution will provide a result that I don't need.

 

In any case I do not understand why the regex does not give to me the expected result in case of "[Points]" input string

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

Hi Summerwind,

 

when your string input contains "[Points]" instead of "number number timestamp" you will get an error from ScanFromString. You could use that error out to decide what to do next...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 6
(2,342 Views)

this could be a possibility

 

but it still does not explain the behavior of the "search" palette

 

 

why does the palette match the "s"?

 

 

in any case, your suggestion is much better than my solution. I already implemented it, and it works like a charm

 

Thank you

0 Kudos
Message 5 of 6
(2,338 Views)

That's an unexpected behavior, I can't reproduce it. What is the offset past match value?

 

regex.png

 

Ben64

0 Kudos
Message 6 of 6
(2,314 Views)