Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^3: How to remove roman numbers

by Khen1950fx (Canon)
on Jun 25, 2012 at 11:19 UTC ( [id://978189]=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (5)
As of 2024-04-23 07:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found