develooper Front page | perl.perl5.porters | Postings from December 2014

Re: All I want for Christmas is: Streaming Regexps

Thread Previous | Thread Next
From:
Lukas Mai
Date:
December 26, 2014 18:35
Subject:
Re: All I want for Christmas is: Streaming Regexps
Message ID:
549DAA52.5070704@gmail.com
Am 25.12.2014 um 16:02 schrieb Paul "LeoNerd" Evans:
> Given a string, $str, and a regexp, $re, I know that the regexp does
> not currently match:
>
>    ok( not $str =~ $re );
>
> However, currently Perl has no way to let me distinguish the two very
> importantly different cases of:
>
>    1) $str contains characters that cause $re not to match
>    2) $str does not contain enough characters to cause $re to match

There's also
3) $str matches $re but adding more characters may make it fail
4) $str matches $re but adding more characters may match more

Example:
3) $str = "foo"; $re = qr/\bfoo\b/;
4) $str = "foo"; $re = qr/\w+/;

I think what I want to know here is whether regexec() reached EOS in any 
way or not.

> -----
>
> In summary:
>
>    I'd like a way to know if a regexp fails to match because it ran out
>    of input but was happy until that point, or if it found some bad
>    characters that adding more input to will never help.
>


-- 
Lukas Mai <plokinom@gmail.com>

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About