In Python:
Given a string 've
, I can catch the start of the string with carat:
>>> import re
>>> s = u"'ve"
>>> re.match(u"^[\'][a-z]", s)
<_sre.SRE_Match object at 0x1109ee030>
So it matches even though the length substring after the single quote is > 1.
But for the dollar (matching end of string):
>>> import re
>>> s = u"'ve"
>>> re.match(u"[a-z]$", s)
>>>
In Perl, from here
It seems like the end of string can be matched with:
$s =~ /[\p{IsAlnum}]$/
Is $s =~ /[\p{IsAlnum}]$/
the same as re.match(u"[a-z]$", s)
?
Why is the carat and dollar behavior different? And are they different for Python and Perl?