Hi ,
 
Im still confused of using word boundaries. After all the help given by 
everyone here ,I have tried other example to get to know what exactly word 
boundaries mean.
 
I'm not trying to extract any particular character ,just playing with word 
boundries to understand more on it.
 
ex: $_="#!chk/usr/bin/perl";
 
1)The output for ---- (\b\W\b) is \ 
Iam looking for some character which is between a word character and non-word 
character,
To my understanding I'm expecting  ! as my asnwer. because starting of the 
string there is # (non-word character) next !  (non word character) next word 
character " c ".
Then answer should be ! ,Right?  can any one explain.
 
Why does it showing result as \ which is between 2 word characters .
 
2) For the same example can any one explain (\b\W) and (\W\b)? Is these are 
valid?
 
 
By the way Im following this link http://www.perl.org/books/beginning-perl/
 
Thanks in advance.
 
 
Best regards,
chandan.
 
 

--- On Tue, 20/7/10, Jim Gibson <jimsgib...@gmail.com> wrote:


From: Jim Gibson <jimsgib...@gmail.com>
Subject: Re: Word boundaries
To: "Perl Beginners" <beginners@perl.org>
Date: Tuesday, 20 July, 2010, 9:29 PM


On 7/20/10 Tue  Jul 20, 2010  2:06 PM, "John W. Krahn" <jwkr...@shaw.ca>
scribbled:

> Rob Dixon wrote:
>> On 20/07/2010 16:22, Chandan Kumar wrote:
>>> 
>>> Small confusion about word boundaries. word boundaries matches
>>> anything between non-word character and word character ,right.
>> 
>> Not quite.
> 
> Quite.
> 
>> /\b/ matches any (zero-length) point in a string between a
>> word and a non-word character,
> 
> Correct.
> 
>> or between a word character and the
>> beginning or end of the string,
> 
> Incorrect.  It matches *only* between \w and \W characters.

Then how are we to interpret this:

% perl -e '
$x = "abc";
if( $x =~ /\ba/ ) {
  print "match\n"; 
}else{
  print "no match\n";
}'
match



-- 
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