Perl : Regular expressions, modifier,substitution,transliteration

#Use of regular expressions #in perl for searching,#substitution and #transliteration.

my $_ = “Kedar ! Kedar! Mandar! Mandar! MJK! KJK!” ;
print “\nOriginal: “,$_;

if ($_=~m/(Kedar\!\ Mandar\!)/)
{ print “\nYou found Kedar! Mandar!”;}

$_== s/Kedar/Mandar/g;
print “\nAfter substituing Kedar with Mandar: “,$_;

$_== tr/Mandar/Jayant/;
print “\nAfter transliterating Mandar with Jayant: “,$_;

Advertisements

Tags: , , , , ,

One Response to “Perl : Regular expressions, modifier,substitution,transliteration”

  1. koolkedar Says:

    Output of the above script is:

    Original: Kedar ! Kedar! Mandar! Mandar! MJK! KJK!

    You found Kedar! Mandar!

    After substituing Kedar with Mandar: Mandar ! Mandar! Mandar! Mandar! MJK! KJK!

    After transliterating Mandar with Jayant: Jayaat ! Jayaat! Jayaat! Jayaat! JJK!
    KJK!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s


%d bloggers like this: