Sunday, 18 August 2013

How to extract the words through pattern matching in perl

How to extract the words through pattern matching in perl

! /usr/bin/perl
use strict;
use warnings;
my $string = "praveen is a good boy";
my @try = split(/([a,e,i,o,u]).*\1/,$string);
print "@try\n";
I was trying to print all words containing 2 adjacent vowels in a string.
o/p : has to be "praveen" and "good" .

No comments:

Post a Comment