Following this post I am attempting the same task, however the regex given below is giving me conflicting results:
$text = "Jiaaah.. RT @mizter_popo";
$pattern = "/(^|[ ])(\RT(?=\s))/";
if(preg_match($pattern, $text)) {
echo "correct";
} else {
echo "wrong";
}
I am expected this to give ‘correct’. Running this in a PHP script on my local server and here returns ‘wrong’. Running the same logic here returns ‘correct’? Can anyone help explain what is going on? Or maybe I am wrong to expect ‘correct’ to be echoed?
For me, removing the
\before theRTworks on both in this specific instance:It is possible the regex tester site are doing some heavy sanitisation to make sure people don’t break their site, which may skew what works and what doesn’t.