in reply to I match a pattern in regex, yet I don't get the group I wanted to extract for some reason
Do not use regular expressions to parse HTML or XML.
use warnings; use strict; use Mojo::DOM; my $dom = Mojo::DOM->new(<<'HTML'); <div id="taglines_content" class="header"> <div class="header"> <div class="nav"> <div class="desc">Showing all 3 taglines</div> </div> </div> <div class="soda odd">Power. Grace. Wisdom. Wonder.</div> <div class="soda even">Wonder. Power. Courage.</div> <div class="soda odd">The future of justice begins with her</div> </div> HTML $dom->find('.soda')->each(sub { print "$_\n" }); __END__ <div class="soda odd">Power. Grace. Wisdom. Wonder.</div> <div class="soda even">Wonder. Power. Courage.</div> <div class="soda odd">The future of justice begins with her</div>
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: I match a pattern in regex, yet I don't get the group I wanted to extract for some reason
by SergioQ (Scribe) on Jan 12, 2021 at 17:47 UTC | |
by haukex (Archbishop) on Jan 12, 2021 at 18:08 UTC | |
by SergioQ (Scribe) on Jan 13, 2021 at 03:22 UTC | |
by haukex (Archbishop) on Jan 14, 2021 at 15:18 UTC |