02-01-2024 03:40 AM
Hello all!
Both VIs are supposed to find the same string part.
Both search inputs are labeled "Regular expression".
Why not as expected?
Solved! Go to Solution.
02-01-2024 03:47 AM - edited 02-01-2024 03:50 AM
It's about the function name (those are functions, not VIs).
The top one is actually "Match Pattern", the bottom one is "Match Regular Expression".
"Match Pattern" was added decades ago. Back then the input name "regular expression" was probably as good as any. It still is a valid name on it's own, just not in the context as we know it now.
"regular expression" is now tightly linked to the PCRE library (mostly compatibly with "Match Regular Expression"). But there's no rule "regular expression" has to be a PCRE expression. It's just an expression that is, well, regular. And the match pattern function does expect an expression that is regular.
02-01-2024 04:23 AM
I suspected something like this. The match pattern function sort of can do regex, but not all. In the end it's a irritatingly named input.
02-01-2024 04:29 AM - edited 02-01-2024 04:30 AM
To complete what Wiebe said, the help of "Match Pattern" says:
"The Match Pattern function is compatible with a limited set of regular expressions and does not support character grouping, alternate pattern matching, backreferences, or non-greedy quantification."
So it is a regular expression, but with fewer options than with function "Match Regular Expression".
Regards,
Raphaël.
02-01-2024 04:48 AM
On the topic of regular expressions:
Add Match Regular Expression sub VI - NI Community
Allow replace with reg ex result in Text Search Results dialog - NI Community
And on that last topic:
Allow replace with empty string in Text Search Results dialog - NI Community
(Shameless plugs)
02-01-2024 07:27 AM
@raphschru wrote:
To complete what Wiebe said, the help of "Match Pattern" says:
"The Match Pattern function is compatible with a limited set of regular expressions and does not support character grouping, alternate pattern matching, backreferences, or non-greedy quantification."
So it is a regular expression, but with fewer options than with function "Match Regular Expression".
Regards,
Raphaël.
I always thought of it as "regex lite".
02-01-2024 08:10 AM
@billko wrote:
@raphschru wrote:
To complete what Wiebe said, the help of "Match Pattern" says:
"The Match Pattern function is compatible with a limited set of regular expressions and does not support character grouping, alternate pattern matching, backreferences, or non-greedy quantification."
So it is a regular expression, but with fewer options than with function "Match Regular Expression".
Regards,
Raphaël.
I always thought of it as "regex lite".
"regex too lite" for me 😁.
02-01-2024 08:38 AM - edited 02-01-2024 08:39 AM
wiebe@CARYA wrote:
@billko wrote:
@raphschru wrote:
To complete what Wiebe said, the help of "Match Pattern" says:
"The Match Pattern function is compatible with a limited set of regular expressions and does not support character grouping, alternate pattern matching, backreferences, or non-greedy quantification."
So it is a regular expression, but with fewer options than with function "Match Regular Expression".
Regards,
Raphaël.
I always thought of it as "regex lite".
"regex too lite" for me 😁.
That's a better description. I actually never use this for that reason. It's either "too complicated" or "not complicated enough" for what I need it to do.
02-02-2024 06:42 AM
wiebe@CARYA wrote:
@billko wrote:I always thought of it as "regex lite".
"regex too lite" for me 😁.
Quite a bit slower though. When Match Pattern is enough it's the much preferred alternative.
This simple test, 100k characters random from ascii 32 - 132 and turned into a constant, then filtered as you can see, takes 6 vs 75 ms!
02-02-2024 08:31 AM
often, I use the regex modus of the function "search and replace string" instead of match pattern.
If you want to search for more complex patterns, such as patterns that contain character grouping, alternate pattern matching, backreferences, or non-greedy quantification, configure the function for advanced regular expression searches or use the Match Regular Expression function.