regexp to match any initial substring of a string?



This is either going to be easy, or impossible; I can't determine
which.

I want to search for words that form any legitimate leading substring
of a long potential string.

So let's say I had the string supercalifragilisticexpialidocious as a
match target, I want to match any word in the set {s su sup supe ...
supercalifragilisticexpialidociou supercalifragilisticexpialidocious}
occurring in the search string. (The search should use greedy matching
so as to suck up as much of the target as it can find)

It doesn't take much thought to realise how tedious this could become
using regexp if you have to define a separate branch for each
possibility. The problem is especially onerous if (such as I have) you
have several such long strings each of which should be tested
against.

Is there a regexp for this?
.



Relevant Pages

  • Re: regexp to match any initial substring of a string?
    ... of a long potential string. ... match target, I want to match any word in the set {s su sup supe ... ... supercalifragilisticexpialidociou supercalifragilisticexpialidocious} ... Is there a regexp for this? ...
    (comp.lang.tcl)
  • Re: regexp to match any initial substring of a string?
    ... of a long potential string. ... match target, I want to match any word in the set {s su sup supe ... ... supercalifragilisticexpialidociou supercalifragilisticexpialidocious} ... Is there a regexp for this? ...
    (comp.lang.tcl)
  • Re: regexp to match any initial substring of a string?
    ... of a long potential string. ... match target, I want to match any word in the set {s su sup supe ... ... supercalifragilisticexpialidociou supercalifragilisticexpialidocious} ...
    (comp.lang.tcl)
  • Re: regexp to match any initial substring of a string?
    ... of a long potential string. ... supercalifragilisticexpialidociou supercalifragilisticexpialidocious} ... set re ^[lindex $letters 0] ...
    (comp.lang.tcl)
  • Re: Regexp, ***= and subexpressions
    ... specified that the user's input be treated as a literal string rather than ... -exact] in cases where regexp isn't required:P ... Seems to be that regexp can't match word boundaries at "non-word" ... But now Earth has rotated and I can get back to sleep. ...
    (comp.lang.tcl)