in reply to Another regex to solve ...
local $_= "Stop tip stoop put up, tops steep 'creap' sleep soap!"; my @words; push @words, $1 # while /(\b\w*(?!(.)\2)\w[aeiou]p\b)/g; while /(\b(?:\w*(?!(.)\2)\w)?[aeiou]p\b)/g; print "( @words )\n"; __END__ ( Stop tip up creap soap )
Update: Changed . to \w so would not match, for example, "no-op" (if you want '-' allowed in words, then replace \w with, for example, [-\w] both places). Then: added (?:...)? to match two-letter words (since my original attempt that handled two-letter words fails because (?<!\2) is not smart enough to realize the fixed length of \2).
- tye
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Another regex to solve ... (more \2)
by tye (Sage) on Aug 18, 2011 at 19:26 UTC |