in reply to How to remove roman numbers

Why do you want another approach? Is yours not working? If yes, please show the code you've written, the result you got and what you wanted instead.

My first crude approach would be s/\b[IVXLCDM]+\s+//g.

Replies are listed 'Best First'.
Re^2: How to remove roman numbers
by Priti24 (Novice) on Jun 25, 2012 at 10:54 UTC

    Thank u mr. moritz for your reply. But Don't you think that if author name start with I , V , M ,etc then it will remove that letter from that name. and author name will be change.

    As \w Match a "word" character , \d Match a decimal digit character, i want to know is there any special character for roman number also

      But Don't you think that if author name start with I , V , M ,etc then it will remove that letter from that name. and author name will be change.

      Why wonder about that if you can simply try?

      As \w Match a "word" character , \d Match a decimal digit character, i want to know is there any special character for roman number also

      Even if it existed it would only help you if the roman numerals were written with special character, for example Ⅰ U+2160 ROMAN NUMERAL ONE instead of I U+0049 LATIN CAPITAL LETTER I

      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.

        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