Open vovayatsyuk opened 8 years ago
Hey,
thanks for the proposition. I know that in the original regex the (.?) is used to. but it seems redundant. . stands for zero or more characters, so why make it a conditional capturing group.
preg_match('!<label(.*?)for="(.*?)parcelshops"(.*?)>(.*?)<\/label>!s', $html, $matches);
I think this could be rewritten as:
preg_match('!<label.*for=".*parcelshops".*>.*<\/label>!s', $html, $matches);
this will result in a single element array $matches when it is matched.
what do you think?
I agree with you.
However, I removed capturing groups added by me, and left groups that was added by module developers.
If module developers will agree too, I will add additional commit to this PR.
Oops, just saw that you are the module developer :)
So I think I should remove all groups and ?
too?
I'm not the original developer :) but I've worked on it quite a bit in the last year. i'll test the new commit as soon as possible and merge it with the master if I can't find any issues.
Hi guys
I would keep the ?
's in the regex, otherwise it is possible it will match multiple <label>
's at once.
See the example at: http://www.regexpal.com/?fam=94132, by default it has 2 matches, but if you remove the question marks, it will match the two <label>
's as one big match, which would be incorrect.
The ?
operand determines how greedy the regex is, if you don't specify it, it will try to match as much as possible, whereas if you use ?
it will try to match as little as possible.
So I vote for keeping the ?
in the regex.
you are right, but what if we use the global 'U' parameter like this:
Ah nice, didn't knew that modifier existed. That's also fine with me :)
This change allows to use multiple attributes inside label tag, to improve module stability, when some third-party modules override shipping methods template.
See http://www.phpliveregex.com/p/el7