Ing. Branislav Gerzo wrote:
Hello all,
Hello,
I have $text = '(this) is just really small test.'; in loop I want get all 2-words and 3-words: 2 words: (this) is is just just really really small small test. 3 words: (this) is just is just really ...and so on This is not a big deal, 2 words I did with: while ($text =~ /(?=(\S+\s+\S+))\S+/g) { print $1, "\n"; } (should be written with \w; \W, but that's no deal) similar will be 3 words. But I have to do it this way by comparing all this words against table, and when something is found put a link. So output should like: '(this) <a href="/foo/bar.html">is just</a> really small test.' I already have routine, which searches table and print back if something found. This is quite hard, I done it with 2 words, but I think it is not optimal and I guess it should be more easy to write 2,3..n word version. Could anyone help me on this ?
$ perl -e' my $text = q/(this) is just really small test./; for my $count ( 1 .. 3 ) { while ( $text =~ /(?=(?:^|\s)(\S+(?:\s+\S+){$count}))/g ) { print "$1\n"; } } ' (this) is is just just really really small small test. (this) is just is just really just really small really small test. (this) is just really is just really small just really small test. John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>