Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re(3): Regex Capturing: Is this a bug or a feature?

by Dog and Pony (Priest)
on Sep 30, 2002 at 09:25 UTC ( [id://201657]=note: print w/replies, xml ) Need Help??


in reply to Re: •Re: Regex Capturing: Is this a bug or a feature?
in thread Regex Capturing: Is this a bug or a feature?

It has bitten me too, and I bet some other people too. I know about it know, and it is ok, but what really lacks is documentation about it.

I seem to recall that it triggers some awkvardness in solutions too, at times, as just because a regexp matches, it may not actually fill all of the $n variables, and old values may still be there, and that makes checking harder. I would have to get back on that with a real example though, in case it is my memory that fools me. :)


You have moved into a dark place.
It is pitch black. You are likely to be eaten by a grue.
  • Comment on Re(3): Regex Capturing: Is this a bug or a feature?

Replies are listed 'Best First'.
Re: Re(3): Regex Capturing: Is this a bug or a feature?
by shotgunefx (Parson) on Sep 30, 2002 at 09:37 UTC
    I believe you're correct. I tried to verify my recollection and came up with something even stranger.
    #!/usr/bin/perl # 5.6.1 use strict; use warnings; my @values = qw ( one var.1 test); getsymbolval(@values); ################################################# sub getsymbolval{ my @syms = @_; foreach my $symbol (@syms){ $symbol=~m/(\w+)(\.)?(\d+)/; print "symbol: $symbol\t\$1: $1\t\$2:$2\n"; my ($ts,$te) = ($1,$2); } wantarray ? @syms : $syms[0]; } __END__

    Output follows (minus uninitilized warnings): What's up with just 'v' being in the regex?
    symbol: one $1: $2:
    symbol: var.1 $1: var $2:.
    symbol: test $1: v $2:
    Very odd.

    -Lee

    "To be civilized is to deny one's nature."

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://201657]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (4)
As of 2024-04-19 22:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found