in reply to Re: doubt in string matching.
in thread doubt in string matching.
In this case also, the output will bemy $find="CXYF"; my $string = "ABCDEFGHIJKLMNOPCDEFQRST";
'CDEF' string foundJust to correct
This combines your first and second solution. Thanks..#!/usr/bin/perl -w use strict; my $string= "ABCDEFGHIJKLMNOPCDEFQRST"; my $find="CDEF"; #extract first and last character my ($first, $last) = $find =~ /([A-Z])[A-Z]*([A-Z])/; #check both character present in string if ($string =~ /$first/ && $string =~ /$last/) { print "'$find' string found" if ($string =~ /$find/); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: doubt in string matching.
by prasadbabu (Prior) on Oct 17, 2006 at 05:50 UTC | |
by Mandrake (Chaplain) on Oct 17, 2006 at 06:47 UTC | |
by prasadbabu (Prior) on Oct 17, 2006 at 06:59 UTC |