freelanceprogrammers.org Forum Index » Perl
Re: [perl_advanced_programmming] Reg: Clarification in Patte
Joined: 21 May 2004
Posts: 44
Re: [perl_advanced_programmming] Reg: Clarification in Patte
>>>>> "Krishna" == Krishna Prasad <skpkrish@...> writes:
Krishna> I have a very small clarification in pattern
Krishna> matching, though it seems to be so silly I`m not able
Krishna> to find a solution, please help me in this regard. I
Krishna> want to match a string into which a particular string
Krishna> should not be present, i.e. You can assume any string
Krishna> which contains lots of words out of which i want to
Krishna> match a pattern in which words starting with "b"
Krishna> should be matched and ending should be "y" and
Krishna> between "b" and "y" no "a" should be present. This
Krishna> can be done using m/b(?!a)y/ig, but it is not working
Krishna> right for me. In detail, i want to search for html
Krishna> tags i.e. <b> and i should match start <b> and end
Krishna> </b> inside of which no <b> tag should be
Krishna> present. Please help me in this regard.
The primary way to do that is to inchworm along:
m{
<b> # match start tag
(?: # begin inchworm group
(?! <b> | </b> ) # while not start or end tag
. # move one character (the inchworm)
) * # for 0 or more times
</b> # match end tag
}xs
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@...> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
All times are GMT
Page 1 of 1
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Freelace Website Designer - Customer web design and software building.
China Wholesale - Electronics Products
Character Studio - Tutorials and Help
China Wholesale - Electronics Products
Character Studio - Tutorials and Help







