Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^2: How to remove roman numbers

by Priti24 (Novice)
on Jun 25, 2012 at 10:54 UTC ( #978183=note: print w/ replies, xml ) Need Help??


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

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


Comment on Re^2: How to remove roman numbers
Re^3: How to remove roman numbers
by Khen1950fx (Canon) on Jun 25, 2012 at 11:19 UTC
    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

Re^3: How to remove roman numbers
by moritz (Cardinal) on Jun 25, 2012 at 11:43 UTC
    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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://978183]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (8)
As of 2014-09-19 05:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (130 votes), past polls