in reply to Re^2: How to remove roman numbers
in thread How to remove roman numbers

As long as there's no word boundry touched, it won't remove the "I" in the author name; however, it will remove the personal pronoun "I". I'd do something like this:
#!/usr/bin/perl -l use strict; use warnings; my(@data) = q( 1. Iilliam H. Schneider, IV 2. William Vassilakis, II 3. Alessandro Calvi, I ); foreach my $data (@data) { $data =~ s/\b[IVXLCDM]+\b//g; chomp $data; print "$data\n"; }
I used "Iilliam" instead of "William" for demonstration purposes.

Replies are listed 'Best First'.
Re^4: How to remove roman numbers
by johngg (Canon) on Jun 25, 2012 at 13:32 UTC

    Unfortunately, you are going to clobber middle initials as well :-(

    knoppix@Microknoppix:~$ perl -E ' > $name = q{John I. Jones, IV}; > say $name; > $name =~ s{\b[IVXLCDM]+\b}{}g; > say $name;' John I. Jones, IV John . Jones, knoppix@Microknoppix:~$

    Perhaps doing something to remove the comma as well and making the assumption that you can anchor to the end of string?

    Cheers,

    JohnGG