--- In [email protected], Julien Pierrehumbert <[EMAIL PROTECTED]>
wrote:
>
> swzoh wrote:
> > IMHO, empty match should be avoided and it's the
> > user's job to do it. When saying that, I think the
> > regex engine should help the user to track down an
> > error in the pattern code. To conclude my opinion, if
> > regex plugin meets an empty match, then it should stop
> > processing immediately and return the results so far.
> >
> > For example, consider regex.mg("abcdef",".*?","\0|").
> > One would expect that the engine immediately escapes
> > the would-be infinite loop and returns only "|".
> > However, in current implementation, it returns
> > "||||||". This could be very confusing.
> What would be confusing is a behaviour that does not
> conform to other implementations. I was told that other
> regex implementations do that as well. If you can show
> me I was misled, I will change the plugin's behaviour.
On the subject of erroneous patterns, there are descriptive errors
available from pcre_compile2() which would be much more useful that
the "8" currently provided by the plugin. Expanded return codes or a
separate service that does nothing but test compiling the pattern and
provides these error codes or corresponding text would be helpful:
0 no error
1 \ at end of pattern
2 \c at end of pattern
3 unrecognized character follows \
4 numbers out of order in {} quantifier
5 number too big in {} quantifier
6 missing terminating ] for character class
7 invalid escape sequence in character class
8 range out of order in character class
9 nothing to repeat
10 operand of unlimited repeat could match the empty string
11 internal error: unexpected repeat
12 unrecognized character after (?
13 POSIX named classes are supported only within a class
14 missing )
15 reference to non-existent subpattern
16 erroffset passed as NULL
17 unknown option bit(s) set
18 missing ) after comment
19 parentheses nested too deeply
20 regular expression too large
21 failed to get memory
22 unmatched parentheses
23 internal error: code overflow
24 unrecognized character after (?<
25 lookbehind assertion is not fixed length
26 malformed number or name after (?(
27 conditional group contains more than two branches
28 assertion expected after (?(
29 (?R or (?digits must be followed by )
30 unknown POSIX class name
31 POSIX collating elements are not supported
32 this version of PCRE is not compiled with PCRE_UTF8 support
33 spare error
34 character value in \x{...} sequence is too large
35 invalid condition (?(0)
36 \C not allowed in lookbehind assertion
37 PCRE does not support \L, \l, \N, \U, or \u
38 number after (?C is > 255
39 closing ) for (?C expected
40 recursive call could loop indefinitely
41 unrecognized character after (?P
42 syntax error after (?P
43 two named subpatterns have the same name
44 invalid UTF-8 string
45 support for \P, \p, and \X has not been compiled
46 malformed \P or \p sequence
47 unknown property name after \P or \p
48 subpattern name is too long (maximum 32 characters)
49 too many named subpatterns (maximum 10,000)
50 repeated subpattern is too long
51 octal value is greater than \377 (not in UTF-8 mode)