From: Richard W.M. Jones Date: Thu, 15 May 2014 19:13:28 +0000 (+0100) Subject: Document behaviour when matching against multiple regular expressions. X-Git-Tag: v1.1~17 X-Git-Url: http://git.annexia.org/?a=commitdiff_plain;h=6d27bfc10be6c01945c73aa4510f1040d3bf7959;hp=329575032af72a3155bcc2640231e603604cd253;p=miniexpect.git Document behaviour when matching against multiple regular expressions. --- diff --git a/miniexpect.pod b/miniexpect.pod index 66ba8c2..b4f0edc 100644 --- a/miniexpect.pod +++ b/miniexpect.pod @@ -257,6 +257,29 @@ for EOF or timeout. C, C, C, C and C are passed through to the L function. +=item * + +If multiple regular expressions are passed, then they are checked in +turn and the I regular expression that matches is returned +I. + +For example if the input is C<"hello world"> and you pass the two +regular expressions: + + regexps[0].re = world + regexps[1].re = hello + +then the first regular expression (C<"world">) may match and the +C<"hello"> part of the input may be ignored. + +In some cases this can even lead to unpredictable matching. In the +case above, if we only happened to read C<"hello wor">, then the +second regular expression (C<"hello">) I match. + +If this is a concern, combine your regular expressions into a single +one, eg. C<(hello)|(world)>. + =back =head2 mexp_expect example