LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Bug? Match Regular Expression

Solved!
Go to solution

Match regular expression:

Why do this work: "<y:NodeLabel.*?>(.*?)<" on this text "<y:NodeLabel fontStyle="bold">MyG#SubClass</y:NodeLabel>"

but this: "<y:AttributeLabel.*?>(.*?)<" doesn't work on this

"<y:AttributeLabel xml:space="preserve">- AttrQueueLock:QUEUE REFNUM
- Ref:U32
- Timeout:BOOL
</y:AttributeLabel>"

 

Have i found a bug of am i missing something about RegExps?

 

(I solved the 2nd with "<y:AttributeLabel.*?>([^<]*)<", but why can't i use the same logic?)

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 1 of 5
(97 Views)
Solution
Accepted by topic author Yamaeda

A "." doesn't match line breaks by default. You can add a dotall "(?s)" modifier to change this.

 

"(?s)<y:AttributeLabel.*?>(.*?)<"

Matches:

"<y:AttributeLabel xml:space="preserve">- AttrQueueLock:QUEUE REFNUM
- Ref:U32
- Timeout:BOOL
<"

Message 2 of 5
(75 Views)
Solution
Accepted by topic author Yamaeda

Because "." matches any character except for line terminators.

"[^<]" matches any character except "<".

Message 3 of 5
(72 Views)

I recommend https://regex101.com to test regex. I would recommend AI to explain this kind of regex questions, but I hate AI (and use it anyway, but wash my mouth afterwards)

Certified LabVIEW Architect
0 Kudos
Message 4 of 5
(61 Views)

Thanks! I thought '.' matched _all_ characters. 🙂

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 5 of 5
(51 Views)