取消
显示结果 
搜索替代 
您的意思是: 

Regular expression != regular expression?

已解决!
转到解答

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 项奖励
1 条消息(共 14 条)
5,055 次查看
解答
已被主题作者 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.

2 条消息(共 14 条)
5,053 次查看

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 项奖励
3 条消息(共 14 条)
5,024 次查看

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.

4 条消息(共 14 条)
5,018 次查看
0 项奖励
5 条消息(共 14 条)
5,005 次查看

@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 项奖励
6 条消息(共 14 条)
4,971 次查看

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

7 条消息(共 14 条)
4,955 次查看

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 项奖励
8 条消息(共 14 条)
4,940 次查看

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
9 条消息(共 14 条)
4,877 次查看

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

 

10 条消息(共 14 条)
4,860 次查看