cancelar
Mostrando resultados para 
Pesquisar então 
Você quer dizer: 

match pattern anomaly?

Hi All,

I must be missing something very obvious here! Can anyone tell me why this VI does not work?

Its a very simple match pattern example which is actually taken from the match pattern VI icon itself:

string: abbc
reg exp: b*   (which to my understanding will match "b" and any number of "b" following immediately after
offset 0

output should be (I think)

before string: a
match pattern: bb
after: c

However I actually get:
before string: <nothing>
match pattern: <nothing>
after: abbc
offset: 0

Where am I going wrong??





0 Kudos
Mensagem 1 de 19
4.251Exibições
I think what you're looking for is a regular expression of:

[b]+

This will match 1 or more consecutive 'b' characters.
intvsteve
LabVIEW R&D
0 Kudos
Mensagem 2 de 19
4.247Exibições
Thanks for your suggestion, it works as you said.

I am still a little uncertain about the behaviour though, as according to the help (LV 7.1 electronic help):

* Matches the longest number of instances of the expression preceding * in regular expression, including zero instances. For example, be*t matches bt, bet, and beet.

But if I use their example
string: beeter
reg exp: b*t

I get:
before: bee
match: t
after: er

This does not seem correct as the wildcard should apply to the b and not the t??



0 Kudos
Mensagem 3 de 19
4.225Exibições
There is something you have overlooked : b*t will match the longest number of instances of b immediately followed by t

Therefore, the function will match : t, bt, bbt, bbbt and so on

So the only match in beeter is t (--> 0 instance of b).
Mensagem 4 de 19
4.215Exibições
thanks for clarifying this, but I am still confused, going back to the original example:

string: abbc
reg ex: b*

surely this should find bb as a match?
Mensagem 5 de 19
4.206Exibições
Good point ! The function should indeed match bb ! I'm also confused now !
b+ works as expected but there seems to be a bug with b*.
Or are we missing something ?

The behavior is the same with LV8.2.1.

0 Kudos
Mensagem 6 de 19
4.196Exibições
Still the behaviour of the function is correct. b* matches 0 or more instances of b. The string starts with 0 instances of b (well, it's a strange way of looking at it but it's true), so position 0 is a match. Before match and match are empty as the whole string is after the match.

Daniel

0 Kudos
Mensagem 7 de 19
4.188Exibições
So if you search for b*c, you should get "bbc" as a return value.

Shane.
Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)
0 Kudos
Mensagem 8 de 19
4.178Exibições
well, it's a strange way of looking at it but it's true

The least would be to change the icon of the match pattenr function because the example it shows produces a different result...
Mensagem 9 de 19
4.170Exibições
I have to disagree, the string abbc contains at least one b, the match pattern is supposed to search within a string so why can't it find the first occurance of the b?

My whole problem stems from the actual LV icon for "Match Pattern"

If you look at the icon, it seems to suggest that if you use "abbc" wired to the input, and b* to the reg exp, then the outputs should be a, bb, and c!

Yet it does not do this...

<edit<> I agree with JB above

Message Edited by nrp on 05-23-2007 03:41 PM

0 Kudos
Mensagem 10 de 19
4.171Exibições