Chandan Kumar wrote:
Hi ,

Hello,

Small confusion about word boundaries. word boundaries matches anything
between non-word character and word character ,right.

Correct.

Here is small example :
$_ = "?Jack do you know the beauty of perl"
print "Enter your text:";
my $pattern =<STDIN>;
chomp $pattern;

if (/$pattern/){
print "1.$1\n";
}

Now say I have given pattern as :(\b\W\b) .what will be the result?

$1 will contain " " (a space character.)

  My understanding  is quotes a  (nonword character) ? a  (nonword
character) followed by word charatcer "j". The result I have expected?.

but result is empty string.

The question mark (?) at the beginning of the string does not have a word character to its left so \b\W\b will not match.



John
--
Any intelligent fool can make things bigger and
more complex... It takes a touch of genius -
and a lot of courage to move in the opposite
direction.                   -- Albert Einstein

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to