Re: Regular Expression Question Why Doesn't this Match?
- From: Mirco Wahab <wahab@xxxxxxxxxxxxxxxxxxx>
- Date: Wed, 01 Nov 2006 09:29:23 +0100
Thus spoke jm (on 2006-11-01 04:51):
does not match this:
My Fictional Co.
But it does match
Product by abc company
Your Regex matches almost everything,
including the empty string. The
term [x]* means: match zero times
or more, which is always given.
The result of the match will be
at lest an empty string.
test it like here:
my $t1 = 'My Fictional Co.';
my $t2 = 'Product by abc company';
my $t3 = '³µ€ Product ü€µ ²~° ';
my $t4 = '';
my $rg = '([\w\s\.\'\-]*)';
print length +($_=~/$rg/), "\n" for $t1, $t2, $t3, $t4
prints (lengths of matches):
which means, in case of $t3 and $t4, there *is* a match,
which is the empty string (length 0).
Is this really what you are trying to do?
- Prev by Date: Re: Regular Expression Question Why Doesn't this Match?
- Next by Date: LWP::UserAgent and non-default outgoing IP
- Previous by thread: Re: Regular Expression Question Why Doesn't this Match?
- Next by thread: FAQ 2.4 I copied the perl binary from one machine to another, but scripts don't work.