Page 1 of 1

regex and hex

Posted: Thu Apr 16, 2009 1:27 pm
by jazz090
i dont know how to specify 0xE2 0x80 0x98 (single left quote) in regex, i have tried:

Code: Select all

/\xE2\x80\x98/
but no luck so far.

Re: regex and hex

Posted: Thu Apr 16, 2009 1:40 pm
by prometheuzz
jazz090 wrote:i dont know how to specify 0xE2 0x80 0x98 (single left quote) in regex, i have tried:

Code: Select all

/\xE2\x80\x98/
but no luck so far.
Works like a charm:

Code: Select all

if(preg_match('/\xE2\x80\x98/', '‘')) {
  echo "YES";
} else {
  echo "nope";
}

Re: regex and hex

Posted: Thu Apr 16, 2009 1:53 pm
by jazz090
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";
}

Re: regex and hex

Posted: Thu Apr 16, 2009 2:04 pm
by prometheuzz
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";
}
You may want to try and add the unicode flag after your regex: '/.../u'
Anyway, the quotes all look the same in my browser, but I guess you're still hacking your way through this SQL escaping stuff: can't help you there.

Best of luck.

Re: regex and hex

Posted: Fri Apr 17, 2009 4:42 pm
by jazz090
ahhhhhhh, the browser encoding was set to western europian instead of UTF8, its solved!