On Mon, Nov 30, 2009 at 12:40 PM, Julia Gallardo Lomeli
<juliaaa...@gmail.com> wrote:
> Hi,
>
> Lets say I want grep to find all <div
> class="photo">whateverElementGoesInsideTheseDivTags</div> in index.html
>
> I am using the code below but it seems that it's not working
>
>
> grep -o "<div class=\"photo\">[^()]*</div>"  index.html
>

Perl's grep can do:

# cat 1.html
<div class="photo">whateverElementGoesInsideTheseDivTags</div>
<div class="photo">(wha)teverElementGoesInsideTheseDivTags</div>
<div class="image">whateverElementGoesInsideTheseDivTags</div>
<div class="css">whateverElementGoesInsideTheseDivTags</div>

# perl -e '@found=grep { m|<div class="photo">[^()]*</div>| } <>;
print @found' 1.html
<div class="photo">whateverElementGoesInsideTheseDivTags</div>

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