Perl_Programmer1992 has asked for the wisdom of the Perl Monks concerning the following question:
#! /usr/bin/perl $what = "coa"; if($what =~ /comm?a/){ print "Matched"; }
Hi monks , I am currently reading about metacharacters , and as per definition the ? metacharacter should match the preceding character zero or 1 time , so that means above code should print "Matched" , but it's not , please correct me where I am wrong , and also I will be very thankful if you can also explain to me the other metacharacters like + , * , (.) and backreferences.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Conceptual doubt in metacharacters : Beginner in perl
by haukex (Archbishop) on Jan 02, 2019 at 09:09 UTC | |
by Perl_Programmer1992 (Sexton) on Jan 02, 2019 at 09:29 UTC | |
|
Re: Conceptual doubt in metacharacters : Beginner in perl
by Athanasius (Cardinal) on Jan 02, 2019 at 07:05 UTC | |
by Perl_Programmer1992 (Sexton) on Jan 02, 2019 at 07:32 UTC | |
by Athanasius (Cardinal) on Jan 02, 2019 at 07:43 UTC | |
by Corion (Patriarch) on Jan 02, 2019 at 08:09 UTC | |
by AnomalousMonk (Archbishop) on Jan 02, 2019 at 18:58 UTC |