I have so many various names
Input:
Depsai P.R.N. Dênis De Castro John D.J. Andrew E. D.J. JOHN JOHN Mical D.J. I need output like this.
D. P.R.N. D. C. J. D.J. A. E. D.J. J. J. M. D.J. If the name like Dênis De Castro i need the output: D. C. If the name contains theses cases (De|Di|Le|La|Van|Der) in between should not capture the first word.
use strict; use warnings; my $gn = qq(<name>Depsai P.R.N.</name> <name>Dênis De Castro</name> <name>Andrew E.</name> <name>John D.J.</name> <name>D.J. John</name> <name>John Mical D.J.</name>); my @int = $gn =~ m{<name>(.*?)</name>}ig; my $ini=(); foreach my $initial(@int){ $ini .= "$1\. " while($initial =~ s/(?:^|[ \.\,\;]+)([A-Z])\w*(\b|$)//s); $ini =~ s/ $//mi; print join("\n",$ini);exit; } Please give some regex pattern. Thanks advance.