Partial matching of regexps 
Author Message
 Partial matching of regexps

Here's a curious problem: Suppose that I have a pattern that a
particular data item is to match.  For instance, for time-of-day, I
have a pattern /^\d\d?:\d\d?(:\d\d?)?$/.  If I have a data item, it's
trivial to check whether it satisfies the pattern: Just do =~.  But
suppose that a user is entering it, character by character, and I want
to check, as each character is being entered, whether what has been
entered could be part of a valid date.

If the regexp were available as a finite automaton, it would be
trivial to check whether a given string was a prefix of a string in
the language.  But I can't see any way to do this in Perl, short of
parsing the regexp and building a new regexp that matches all prefixes
of the original regexp.  (Which isn't too hard, conceptually, but the
process of parsing a Perl regexp is pretty messy.)

Is there a better way?


Well, so much for the unicorns.  From now on, all carnivores will be
confined to C deck.     -- Gary Larsen, "The Far Side"

Wed, 21 Sep 1994 11:37:03 GMT  
 [ 1 post ] 

 Relevant Pages 

1. Detecting success on partial match with capture?

2. Partial matching of a regular expression

3. Finding partial match

4. Finding all regexps matches at once?

5. Still stumped on match regexps

6. Multiline regexps with matches

7. matching word boundaries with regexps

8. Help needed: Regexps (pattern matching) with hashes?!

9. regexps with index(), regexps vs strings, clarify $*

10. Perl regexps compared to Python regexps

11. partial buffered writes

12. Partial Success installing Perl on Solaris 2.2


Powered by phpBB® Forum Software