in reply to Re^3: How do I check a string for dupicate text?
in thread How do I check a string for dupicate text?

$field =~ s/\b(.+)\b\s*\1\b/$1/g;

Beware! Depending on what else there is in the string after apart from the (possibly repeated) firstname + lastname, this regex can be highly dangerous.

Consider:

my $field = "Jo Doe (Tel: 999-111-111)"; $field =~ s/\b(.+)\b\s*\1\b/$1/g; print $field;

Oops! What's happened to Joe Doe's phone number??

Replies are listed 'Best First'.
Re^5: How do I check a string for dupicate text?
by ikegami (Patriarch) on Sep 11, 2004 at 19:48 UTC
    aye, #3 and #4 remove duplicates bits anywhere in the string, as stated in my original reply.