LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Regex to find spaces not preceded by a colon

Solved!
Go to solution

Hi All,

 

With my limited understanding of regex, I am trying to find a space that is not preceded by a colon.  Trying "(?<!:)" on regex101 works: 

JohnEE_0-1745354388988.png

but not when I use the Match Pattern VI.  Does that VI not work with a negative look behind?  Am I formatting it wrong?  Is there a better way to do my search?

 

Thanks!

 

John

0 Kudos
Message 1 of 4
(793 Views)
Solution
Accepted by topic author JohnEE

Match Pattern uses a limited set of regular expressions. Try using Match Regular Expression.vi instead.

 

Ben

Message 2 of 4
(782 Views)

Plain ol' Match Pattern should suffice for something this simple.  I neglected to save and attach a VI, but this is pretty self-explanatory:

 

DavidBoyd_0-1745357895294.pngDavidBoyd_1-1745357926824.png

EDIT: since the primitive doesn't support capturing groups (the parenthesis syntax), the match substring output will include the non-colon character immediately preceding the space of interest.  I'll assume you're mostly interested in the offset past match numeric.

 

Hope this helps!

 

Best regards,

Dave

David Boyd
Sr. Test Engineer
Abbott Labs
(lapsed) Certified LabVIEW Developer
Message 3 of 4
(764 Views)

Thanks Dave and Ben,

 

I didn't realize that Match Pattern used a more limited version of regex.  I thought I only needed Match Regular Expression if I needed sub-matches, etc.  Since I was trying to break apart a string, using the space not preceded by a colon as the delimiter, Match Regular Expression in a loop seems the way to go.

 

Thanks again!

Regards,

 

John

0 Kudos
Message 4 of 4
(684 Views)