Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
It produces two hits - an "a" and an empty string. Yet if both conditions fail (by changing $_ to "zzzzz"), it produces no hits, as expected. Why the empty string? And can I avoid it, other than by post-processing @hits? Thanks!$_ = "caaat"; my @hits = m/(?:c(a)|k(t))/g; foreach (@hits) { print "|$_|\n" }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: empty hits with regex
by GrandFather (Saint) on Oct 02, 2008 at 18:56 UTC | |
|
Re: empty hits with regex
by ikegami (Patriarch) on Oct 02, 2008 at 19:21 UTC | |
by JavaFan (Canon) on Oct 02, 2008 at 20:38 UTC | |
by Tanktalus (Canon) on Oct 02, 2008 at 22:52 UTC |