We've become fairly adept at generating various regular expressions to match input strings, but we've been asked to try to validate these strings iteratively. Is there an easy way to iteratively match the input string against a regular expression?

Take, for instance, the following regular expression:

`[EW]\d{1,3}\.\d`

When the user *enters* "E123.4", the regular expression is met. How do I validate the user's input *while they type it*? Can I partially match the string "E1" against the regular expression?

Is there some way to say that the input string only partially matched the input? Or is there a way to generate sub-expressions out of the master expression automatically based on string length?

I'm trying to create a generic function that can take any regular expression and throw an exception as soon as the user enters something that cannot meet the expression. Our expressions are rather simple in the grand scheme of things, and we are certainly not trying to parse HTML :)

Thanks in advance.
David