pedrete has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks...!!

i have "silly"? question for you, please....

in Perl regex... what is the behaviour of an asterisk with no preceding token????

an example of my doubt:

This:
.*@abc.com matches monks@abc.com
ok so far...

BUT...

this:

*@abc.com  also matches!!!!!!!!!
WHY????

Thanks!
Pedrete.

Replies are listed 'Best First'.
Re: Regex: Asterisk with NO preceding token
by beech (Parson) on Feb 10, 2016 at 08:17 UTC

    in Perl regex... what is the behaviour of an asterisk with no preceding token????

    Its an error

    $ perl -le " /*/" Quantifier follows nothing in regex; marked by <-- HERE in m/* <-- HER +E / at -e line 1.

    also matches!!!!!!!!! WHY????

    I don't think it does that.

    You should post real code with real output from that code that shows * matching something and not generating an error.