in reply to Re: Regex - Matching prefixes of a word
in thread Regex - Matching prefixes of a word
I actually did use that pattern in a few limited other places in the code, but as far as I see, it can only be practically used after you've parsed out a parameter and want to know what things that specific parameter matches.
>replace officer sci with Spock if ($command =~ /^(?:replace\s+)?officer\s+([a-z]+)\s+with ([a-z]+)/i) { $crewStation = $1; $newOfficerName = $2; $officer->{science} = $newOfficerName if ('science' =~ /$crewStation +/); ... }
I don't see how that trick could be used like a subexpression to help out the first command recognition regex. (Being usable as a subexpression is critical)
However, I do very much like the idea of grepping over a list of keywords in order to make synonyms trivial to add.
|
|---|