regex and hex
Posted: Thu Apr 16, 2009 1:27 pm
i dont know how to specify 0xE2 0x80 0x98 (single left quote) in regex, i have tried:
but no luck so far.
Code: Select all
/\xE2\x80\x98/A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
Code: Select all
/\xE2\x80\x98/Works like a charm:jazz090 wrote:i dont know how to specify 0xE2 0x80 0x98 (single left quote) in regex, i have tried:
but no luck so far.Code: Select all
/\xE2\x80\x98/
Code: Select all
if(preg_match('/\xE2\x80\x98/', '‘')) {
echo "YES";
} else {
echo "nope";
}Code: Select all
if(preg_match('/‘/', $subject)) {
echo "YES";
}else {
echo "nope";
}You may want to try and add the unicode flag after your regex: '/.../u'jazz090 wrote:yes but that will match (‘) in a string, not (‘). note that those are not 3 seperate hexs, they are ONE hex
i want this basicly but (left quote marked as hex)
Code: Select all
if(preg_match('/‘/', $subject)) { echo "YES"; }else { echo "nope"; }