artifact has asked for the wisdom of the Perl Monks concerning the following question:
how do i match a particular alphabet using regexp? I cannot print the second occurrence of 'a' in my string in the following piece of code,as a beginner I cannot find where the problem is and why it is happening?
#! usr/bin/perl use warnings; use strict; my @vars; $_='1: A a A silly a sentence a (495,a) *BUT* one a which is a will be + useful. (3)'; if (@vars= /(\s)(a)(\s)/ig){ print "the text matches the pattern '\$pattern'.\n"; foreach (@vars) { print "Group: $_\n"; } } else { print " it was not found. \n"; } print "@vars\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: problem using regexp
by AnomalousMonk (Archbishop) on Jul 28, 2012 at 01:33 UTC | |
by artifact (Novice) on Jul 29, 2012 at 16:15 UTC | |
|
Re: problem using regexp
by choroba (Cardinal) on Jul 27, 2012 at 20:30 UTC | |
by artifact (Novice) on Jul 29, 2012 at 16:01 UTC | |
|
Re: problem using regexp
by Grimy (Pilgrim) on Jul 27, 2012 at 20:36 UTC | |
by artifact (Novice) on Jul 29, 2012 at 16:05 UTC |