$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??
In reply to Re^4: How do I check a string for dupicate text?
by Not_a_Number
in thread How do I check a string for dupicate text?
by devgoddess
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |