in reply to Conceptual doubt in metacharacters : Beginner in perl
Hello Perl_Programmer1992, and welcome to the Monastery!
“The preceding character” means the single, immediately preceding character, in this case m. But the character before that — another m — is not present in the string held by the variable $what, so there is no match. If you change the regex to /com?a/, it matches.
Other metacharacters: + matches one or more of the preceding character; * matches zero or more of the preceding character; . (dot) matches any one (single) character (except a newline). Parentheses () are used for capturing: reading from left to right, the captured strings are available in the special variables $1, $2, etc. See “Metacharacters” under perlre#The-Basics.
Hope that helps,
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Conceptual doubt in metacharacters : Beginner in perl
by Perl_Programmer1992 (Sexton) on Jan 02, 2019 at 07:32 UTC | |
by Athanasius (Archbishop) 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 |