develooper Front page | perl.perl6.language | Postings from April 2003

Re: Ruminating RFC 93- alphabet-blind pattern matching

Thread Previous | Thread Next
From:
Piers Cawley
Date:
April 7, 2003 11:35
Subject:
Re: Ruminating RFC 93- alphabet-blind pattern matching
Message ID:
m2he9anog3.fsf@TiBook.bofh.org.uk
"Joseph F. Ryan" <ryan.311@osu.edu> writes:

> Yary Hluchan wrote:
>
>>>making *productions* of strings/sounds/whatever that could possibly
>>>match the regular expression?
>>>
>>>
>>>>Correct me if I am wrong, but isn't this the :any switch of apoc 5?
>>>>http://www.perl.com/pub/a/2002/06/26/synopsis5.html
>>>>
>>
>>Not really, unless the input string is infinite!
>>
>
>
> Well, thats just in the general purpose case, right?  That's because
> a regex like /a*/ matches:
>
> 'w'
> 'qsdf'
> 'i bet you didn't wnt this to mtch'
>
> So, you're going to need some sort of controlled input to a regex match
> with the :any for it to work right.
>
> Here's my approach to the problem: generate a possible string that
> could match every atom in the regex individually, and then generate
> matches for the whole regex off of that.  I liked Luke's approach
> of stapling methods onto the Rx classes, so I used an approach that
> made use of that idea.  I completed each of the needed rules, since
> the methods in my example are pretty simple (they probably would be
> in Luke's example too, but I just wanted to be sure I wasn't missing
> anything).

[...]

>
> So, given a call like:
>
>     generate (/(A*B*(C*|Z+))/, 4);
>    The C<$string> variable in the 2nd line of C<generate> would become:
>
>     AAAABBBBCCCCZZZZ
>
> And the :any switch takes care of the rest. (-:

Sadly, no it doesn't, the rule given should match 'AZZZ', but that's
not a substring of the string you generated. 

-- 
Piers

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