in reply to Checking whether a string is a prefix of any string matching a given regular expression

I think the technique used in Generating regex strings with a regex might be adapted to your problem. Using (?{}) blocks allows you to get inside regex processing to a degree.

The Regexp::Genex module based on the above transforms a regex using YAPE::Regex, you could write a similar transform to answer your question. The transformed version would have to be peppered with an illegible sequence of (?{}) terms although I don't know what form it would take. Something like:

/^(\d(\d(\d(-(\d(\d(\d$)|$)|$)|$)|$)|$)|$)/
  • Comment on Re: Checking whether a string is a prefix of any string matching a given regular expression
  • Download Code