LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Regular expression != regular expression?

Solved!
Go to solution

Hello all!

 

Both VIs are supposed to find the same string part.

MaSta_0-1706780375851.png

Both search inputs are labeled "Regular expression". 

Why not as expected?

0 Kudos
Message 1 of 14
(1,132 Views)
Solution
Accepted by MaSta

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.

Message 2 of 14
(1,130 Views)

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.

0 Kudos
Message 3 of 14
(1,101 Views)

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.

Message 4 of 14
(1,095 Views)

@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".

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 6 of 14
(1,048 Views)

@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 😁.

Message 7 of 14
(1,032 Views)

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.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 8 of 14
(1,017 Views)

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!

Yamaeda_0-1706877738543.png

 

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

Qestit Systems
Certified-LabVIEW-Developer
Message 9 of 14
(954 Views)

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.

alexderjuengere_0-1706883933687.png

 

Message 10 of 14
(937 Views)