03-20-2026 04:42 AM
wiebe@CARYA wrote:
I do miss a few things Python can do, like calling custom functions from a reg.ex.. That would be very powerful, for things like capitalizing start of words, or incrementing numbers, etc.. These things require loops, cases and shift registers in LabVIEW. I suppose LabVIEW could do that by providing a (array of) (strong typed) VI server input... But the only way I see it happening is if we make it and show it off to NI.
I found a regexp that can capitalize words, but LV doesn't support \u ...
03-20-2026 05:05 AM
@Yamaeda wrote:
wiebe@CARYA wrote:
I do miss a few things Python can do, like calling custom functions from a reg.ex.. That would be very powerful, for things like capitalizing start of words, or incrementing numbers, etc.. These things require loops, cases and shift registers in LabVIEW. I suppose LabVIEW could do that by providing a (array of) (strong typed) VI server input... But the only way I see it happening is if we make it and show it off to NI.I found a regexp that can capitalize words, but LV doesn't support \u ...
PCRE and PCRE2 don't support the Perl \u escape sequence.
from PCRE2 documentation:
Unsupported escape sequences
In Perl, the sequences \F, \l, \L, \u, and \U are recognized by its string handler and used to modify the case of following characters. By default, PCRE2 does not support these escape sequences in patterns. However, if either of the PCRE2_ALT_BSUX or PCRE2_EXTRA_ALT_BSUX options is set, \U matches a "U" character, and \u can be used to define a character by code point, as described above.
03-20-2026 11:55 AM
@Martin_Henz wrote:
@Yamaeda wrote:
wiebe@CARYA wrote:
I do miss a few things Python can do, like calling custom functions from a reg.ex.. That would be very powerful, for things like capitalizing start of words, or incrementing numbers, etc.. These things require loops, cases and shift registers in LabVIEW. I suppose LabVIEW could do that by providing a (array of) (strong typed) VI server input... But the only way I see it happening is if we make it and show it off to NI.I found a regexp that can capitalize words, but LV doesn't support \u ...
PCRE and PCRE2 don't support the Perl \u escape sequence.
Spoilerfrom PCRE2 documentation:
Unsupported escape sequences
In Perl, the sequences \F, \l, \L, \u, and \U are recognized by its string handler and used to modify the case of following characters. By default, PCRE2 does not support these escape sequences in patterns. However, if either of the PCRE2_ALT_BSUX or PCRE2_EXTRA_ALT_BSUX options is set, \U matches a "U" character, and \u can be used to define a character by code point, as described above.
@Martin_Henz wrote:
@Yamaeda wrote:
wiebe@CARYA wrote:
I do miss a few things Python can do, like calling custom functions from a reg.ex.. That would be very powerful, for things like capitalizing start of words, or incrementing numbers, etc.. These things require loops, cases and shift registers in LabVIEW. I suppose LabVIEW could do that by providing a (array of) (strong typed) VI server input... But the only way I see it happening is if we make it and show it off to NI.I found a regexp that can capitalize words, but LV doesn't support \u ...
PCRE and PCRE2 don't support the Perl \u escape sequence.
Spoilerfrom PCRE2 documentation:
Unsupported escape sequences
In Perl, the sequences \F, \l, \L, \u, and \U are recognized by its string handler and used to modify the case of following characters. By default, PCRE2 does not support these escape sequences in patterns. However, if either of the PCRE2_ALT_BSUX or PCRE2_EXTRA_ALT_BSUX options is set, \U matches a "U" character, and \u can be used to define a character by code point, as described above.
But I think \U sets case sensitivity.
That's not enabling replacing all a -> A, or 1 -> one.
An inlined function would be able to do that.
import re
def uppercase(match):
text = match.group(1)
return text.upper()
pattern = r"<b>(.*?)</b>"
text = "This is <b>bold</b> text."
result = re.sub(pattern, uppercase, text)
print(result)
03-22-2026 03:03 PM
This example with uppercase/lowercase can be done entirely by PCRE2.
Yes, of course, I still needed a few hours now, because my PCRE2 library was not yet ready to be able to demonstrate that and that package is still a few hours away from release.
Much more complicated changes are, however, not possible with PCRE2 alone.
03-23-2026 12:47 PM
wiebe@CARYA wrote:
@raphschru wrote:
wiebe@CARYA wrote:
@raphschru wrote:
I'd personally use a positive lookahead to have the replace string contain exactly what I want to insert:
I never remember the syntax of those look arounds when I need them, so I don't use them unless I have to. They are quite powerful..
I often go to https://regex101.com/.
The Quick Reference section is wonderful for finding the syntax I need.
I have a copy of O'Reilly Python Pocket Reference (9781449357016). 2,- EU at a thrift shop.
It has 2 paragraphs that summarize everything about reg.ex.'s.
I don't use it for anything else (since it's about Python).
I do miss a few things Python can do, like calling custom functions from a reg.ex.. That would be very powerful, for things like capitalizing start of words, or incrementing numbers, etc.. These things require loops, cases and shift registers in LabVIEW. I suppose LabVIEW could do that by providing a (array of) (strong typed) VI server input... But the only way I see it happening is if we make it and show it off to NI.
OpenG libs have LabVIEW native functions for capitalizeing, etc...
OpenG String Library Toolkit for LabVIEW - Download - VIPM by JKI
07-23-2026 07:36 PM
I released the PCRE2 Toolkit for LabVIEW. It is based on PCRE2 Version 10.47 and supports named patterns, substitutions (see here for more information) and the jit (just in time) compiler.
07-24-2026 05:52 PM
07-25-2026 03:23 AM
@JÞB wrote:
This brings to mind the old joke:
A programmer says "I have a problem."
The manager says "use a regex!"
The programmer now has 2 problems.
OTOH a clean and concise communication channel between sender and recipient would be highly preferred!
The string sent is wrong wrong wrong! Have it disambiguated!
😀
It might not be the best place for my post. There are some posts here in the forum where a relatively simple regex crashes LabVIEW. Would it be better there? I don't think so.
PCRE/PCRE2 is like any programming language, like any extensive library. You have to like it, otherwise it's pointless. Anyone who likes PCRE will easily hit the limits of the XNode 'Match Regular Expression'. Anyone who doesn't like PCRE should avoid 'Match Regular Expression'.
07-25-2026 02:41 PM
@Martin_Henz wrote:
There might be some more complicated ways, but for me it would be enough if the Call Library Function Node (CLFN) configuration dialog box provides a parameter type pointer to function" which allows the selection of a DLL (library name or path) and the name of the function. This yould allow to create a DLL/DLL function with LabVIEW an use that function for the callback. Soemthing like this...
You clearly don't understand function pointers. A function is more than just a pointer. It is also a stack frame (and for 64-bit Windows according CPU registers) to pass parameters to. The caller needs to setup that stack frame and possible CPU registers EXACTLY in the way that function was compiled for, otherwise you get a stack corruption and/or invalid function parameters and the whole software goes into a General Protection Fault rather sooner than later.
07-26-2026 07:33 AM - edited 07-26-2026 07:37 AM
@rolfk wrote:
You clearly don't understand function pointers.
You are probably right in general. I have very rarely used function pointers in recent years.
That said, there seems to be a misunderstanding. What I proposed isn't rocket science; it works right now. It would just be a bit easier to implement if LabVIEW offered it as a built-in feature.
I’m sticking with PCRE2 for now because I have it on hand and it offers multiple ways to use a callback function and no hardware is needed. One case relates to the regular expression itself, while another can be called during the matching operation.
The callback function is as follows:
int (*pcre2_callout)(pcre2_callout_block *, void *);
The function
int pcre2_callout_enumerate(const pcre2_code *code, int (*callback)(pcre2_callout_enumerate_block *, void *), void *user_data);
invokes the callback. It relates to the regular expression.
The other function,
int pcre2_set_callout(pcre2_match_context *mcontext, int (*callout_function)(pcre2_callout_block *), void *callout_data);
causes `callout_function` to be invoked during the matching process.
The attached ZIP file contains two projects:
1. CalloutFuncDll creates a DLL (CalloutFuncDll.dll). This contains the callback functions `DemoCalloutFunction1` (for `pcre2_callout_enumerate`) and `DemoCalloutFunction2` (for `pcre2_match`).
2. The CalloutDemo project uses the generated CalloutFuncDll.dll.
It calls `pcre2_callout_enumerate()`, which results in `DemoCalloutFunction1()` (from the previously created DLL) being called three times. Similarly, `DemoCalloutFunction2()` is called three times from `pcre2_match()`.
Note: The example is for LabVIEW 64 Bit and does not perform any error checking in certain places. But my point isn't to show what proper error handling might look like, either 🙂