I'm confused.
tachyon posted an interesting solution, but i can't makes any sense of it.
first of all, i could find no mention of /c in perlman:perlre, but perl didn't barf on it -- so what does it do?
second, i tried the following near-identical code and it didn't do at all what i expected:.. it printed:#!/usr/bin/perl -w use strict; my $string = "foo bar baz bar quux foo gin"; my @list = qw(foo bar); $string =~ m/\Q$_\E/gc for @list; my ($rest) = $string =~ m/\G(.*)$/; print "$rest\n";
and honestly, i can't see how it could possibly work the way you wanted it to. it seems to me that the /g on the m// would cause the 'foo' to match at the first and sixth words, and then the 'bar' to match at words 2 and 4, leaving the \G assertion after word 4, not after word 2 where i think it belongs.foo bar baz bar quux foo gin
obviously, i'm missing some of what's going on here. can you enlighten me?
In reply to Re: Re: getting the first n printable words from a string of HTML
by Vynce
in thread getting the first n printable words from a string of HTML
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |