>
> brucexs wrote:
> > global bbb
> > win.debug(re.create("abcd").fullmatch("abcd","bbb"))
> > win.debug(bbb)
>
> This is wrong. Remember you must use the right number of variables?
Oops! I had thought the first variable was supposed to capture the
whole match. In fact, I noticed stuff like
re.create("(a)(b)(c)").fullmatch("abc","v1,"v2","v3")
worked in a fashion, except I was still expecting v1 to hold the full
matched string.
However, I have gone back to read the examples, and there is an
example which illustrates the exact error I made!
// Example: fails because there aren't enough sub-patterns:
// !pcrecpp::RE("\\w+:\\d+").FullMatch("ruby:1234", &s);
So I should have written
win.debug(re.create("(abcd)").fullmatch("abcd", "bbb"),bbb)
which works as I expected.
I will test it some more now that I understand this point.
works
> because it's sending an empty string:
> win.debug(re.create("abcd").fullmatch("abcd",""))
Becuase it is an empty string. Once the plugin finds an empty
string, it assumes it has found the last argument. So above is same
as omitting the ,"".
>
> But you still need to initialise the string somehow, right? Does
this:
> string s[MAX_STRINGARGS];
> actually initialise MAX_STRINGARGS strings? If so, we can remove
the
> whole for loop, right?
It should, because it calls the constructor for each element.
Defaults to "", I imagine.
However, its probably not worth fixing now that I understand my error.
Notice by the way that the plugin does not support calls like
re.create("(ab)(cd)").fullmatch("abcd", "", "bbb")
which is trying to grab only the second match. The docs for pcrecpp
says that it does, although looking at the code which scans args in
fullmatch, it seems to me he also stops looking at args when he finds
a missing one. But I may be wrong.
Since you can just use
re.create("(ab)(cd)").fullmatch("abcd", "ignore", "bbb")
I don't see this as a big deal.
I did notice that there is a leak in my plugin if the re constructor
of pcrecpp fails and I set error string. I should delete the re
object that is created when I set the error message. Probably not
going to happen that much.
>