in reply to Re^5: search of a string in another string with 1 wildcard
in thread search of a string in another string with 1 wildcard

How to add + and space to the construct? So instead of

my $pattern = qr{ab[crdnfqm]def}; my $pattern = qr{ab[crdnfqm\+\s]def};

will be correct? to be used with your solution

if $string =~ m{ ($pattern) };

Replies are listed 'Best First'.
Re^7: search of a string in another string with 1 wildcard
by AnomalousMonk (Archbishop) on Oct 15, 2014 at 14:58 UTC

    The regex definition  qr{ab[crdnfqm\+\s]def}; does add a  '+' character and the class of all whitespace characters to the  [crdnfqm] character class contained in the previous  qr{ab[crdnfqm]def}; definition. Note, however, that  m{ ($pattern) } (still) requires a blank (0x20) character before and after  $pattern in order to have a match. (NB: The  '+' character is not special, i.e., is not a metacharacter, inside a character class and so does not need the  \ escape — but it does no harm.)

    Please see perlre, perlrecharclass, perlrequick, and perlretut.