in reply to Re: Re: Zipcode Regex Help
in thread Zipcode Regex Help

What did you expect it to return? Consider this
my $bar = 'asdf asdf asdf-rdf'; my $mor = () = $bar =~ /asdf(?:-rdf)?/; my $gor = () = $bar =~ /asdf(?:-rdf)?/g; my @gor = $bar =~ /asdf(?:-rdf)?/g; warn scalar @gor; die "$mor and $gor = @gor"; __END__ 3 at - line 6. 1 and 3 = asdf asdf asdf-rdf at - line 7.
update:
It returns the number of times the entire pattern matched ( aka the number of total matches). .
My apologies. What's returned are the values of the capture buffers (parens create a capture buffer). my $mor = () = $bar =~ /asdf(?:-rdf)?/; could be rewritten as my $gor = my @gor = $bar =~ /asdf(?:-rdf)?/g;

MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
** The third rule of perl club is a statement of fact: pod is sexy.

Replies are listed 'Best First'.
Re: Re: Re: Re: Zipcode Regex Help
by tcf22 (Priest) on Jun 25, 2003 at 21:57 UTC
    For zipcode 12345, I would expect it return 1, since only (12345) matched, and not (6789), but I guess because of the '?' in (6789)?, it counts it as a match.