in reply to Re^3: Simple regexp question
in thread Simple regexp question

Test before contradicting someone.

print('*' =~ /^[*]$/ ? 'match' : 'no match', "\n"); # match print(']' =~ /^[*]$/ ? 'match' : 'no match', "\n"); # no match print('' =~ /^[*]$/ ? 'match' : 'no match', "\n"); # no match

Only \, ^ (depending on position), - (depending on position), ], the sequence [:...:] and the regexp delimiter are special in character classes.

Replies are listed 'Best First'.
Re^5: Simple regexp question
by SamCG (Hermit) on Mar 31, 2006 at 17:07 UTC
    I'd add

    perl -e "print (';' =~ /[];]/ ?'match':'nomatch');" prints "match"

    the ] is also depending on position

    update: fixed typo