Using alternate with parentheses : parentheses « Regular Expression « Perl






Using alternate with parentheses

   

#!usr/bin/perl

use strict;
use warnings;

my $string1 = "hello";
my $string2 = "hello there";
my $string3 = "hi there";

print "$string1\n$string2\n$string3\n";

print "1: how are you?\n" if ( $string1 =~ m/(hello|hi) there/ );
print "2: how are you?\n" if ( $string2 =~ m/(hello|hi) there/ );
print "3: how are you?\n" if ( $string3 =~ m/(hello|hi) there/ );

   
    
    
  








Related examples in the same category

1.Using alternate without parentheses
2.Parentheses and regex