in reply to regexp to match repeated charater
If I have understood the question correctly, you're looking for the spaceship goats.cx operator.
#! /usr/bin/perl use strict; use warnings; my $str = 'It was an intelligent stori'; for my $word (split / /, $str) { my $nr =()= $word =~ /(i)/gi; if ($nr > 0) { print "$word has $nr $1\n"; } }
(No, there's not really such an operator, it's more an emergent effect of forcing a global match's list context into scalar context by assigning the result to (), the empty list).
• another intruder with the mooring in the heart of the Perl
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: regexp to match repeated charater
by Codon (Friar) on Aug 28, 2007 at 19:52 UTC | |
by grinder (Bishop) on Aug 29, 2007 at 08:52 UTC |