I find this behavior slightly strange:
pattern = re.compile(r"test")
print pattern.match("testsda") is not None
True
print pattern.match("astest") is not None
False
So, when the string doesn't match the pattern at its end, everything is fine. But when the string doesn't match the pattern at its beginning, the string doesn't match the pattern anymore.
By comparison, grep succeeds in both cases:
echo "testsda" | grep test
testsda
echo "adtest" | grep test
adtest
Do you know why this is happening ?