in reply to most efficient regex to delete duplicate words
Very simply, it finds a word followed by some non-word thing, followed by the same word (one or more times), and replaces it with the original word.$word = qr{ \w [\w'-]* }x; $nonword = qr{ [^\w'-]+ }x; $text =~ s{ \b ($word) (?: $nonword \1 )+ (?! \w ) # UPDATE }{$1}xg;
_____________________________________________________
Jeff[japhy]Pinyan:
Perl,
regex,
and perl
hacker.
s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;
|
|---|