in reply to Conceptual doubt in metacharacters : Beginner in perl

I will be very thankful if you can also explain to me the other metacharacters like + , * , (.) and backreferences

perlretut is a good start. For your question:

coacomacommacommmacommmma
/com?a/
/com*a/
/com+a/
/co(mm)?a/
/co(m|mmm)a/
/com{2}a/
/com{0,2}a/
/com{2,3}a/
/com{3,}a/
use warnings; use strict; use HTML::Tiny; my @tests = map { 'co'.('m'x$_).'a' } 0..4; my @regexes = do { no warnings 'qw'; qw/ com?a com*a com+a co(mm)?a co(m|mmm)a com{2}a com{0,2}a com{2,3}a com{3,}a / }; my $h = HTML::Tiny->new; print $h->table( {border=>1,cellpadding=>3,cellspacing=>0}, [ \'tr', [ \'td', '', map { $h->code($_) } @tests ], map( { my $r=$_; [ \'td', $h->code("/$r/"), map( { /$r/ ? $h->tag('font', {color=>'green'}, '✔') : $h->tag('font', {color=>'red'}, '✘') } @tests ), ] } @regexes ), ] );

Replies are listed 'Best First'.
Re^2: Conceptual doubt in metacharacters : Beginner in perl
by Perl_Programmer1992 (Sexton) on Jan 02, 2019 at 09:29 UTC

    Thanks a ton my friend ! , I will save this table and below code for future reference , "Thanks !" x 100 :-)