How the regular should match data like Xf0x9fx91xab

Source: Internet
Author: User
I should be how to match \xf0\x9f\x91\xab. Please help! How to write an expression??


Reply to discussion (solution)

$s = "\xf0\x9f\x91\xab"; Var_dump (Preg_match ('/\xf0\x9f\x91\xab/', $s));

$s = "\xf0\x9f\x91\xab"; Var_dump (Preg_match ('/\xf0\x9f\x91\xab/', $s));


Then you can only match one AH. This is just one of them.


$s = "\xf0\x9f\x91\xab"; Var_dump (Preg_match ('/\xf0\x9f\x91\xab/', $s));


Then you can only match one AH. This is just one of them.
Please post the need to match all the content!!



$s = "\xf0\x9f\x91\xab"; Var_dump (Preg_match ('/\xf0\x9f\x91\xab/', $s));


Then you can only match one AH. This is just one of them.
Please post the need to match all the content!!
Like this: Hello, \xf0\x9f\x98\x83 I am very \xf0\x9f\x86\x93 today. This binary is not deterministic.

If your string is utf-8, I am not mistaken, \xf0\x9f\x98\x83, etc. is a delimiter, the entire string should only have several forms, should be considered as a character (no word, only the placeholder, the role of separation)
If your string comes from an API, you might want to check out the documentation for this API.

I have said it in another post of yours, but your perception is too bad
Rule string:/\xf0.../

$s = "This is just the test text \xf0\x9f\x98\x83 in the program, in fact the emoji are \xf0\x9f\x86\x93 in the inner code. ";p reg_match_all ('/\xf0.../', $s, $r); foreach ($r [0] as $v) echo current (unpack (' h* ', $v)), Php_eol;
f09f9883
f09f8693

I have said it in another post of yours, but your perception is too bad
Rule string:/\xf0.../

$s = "This is just the test text \xf0\x9f\x98\x83 in the program, in fact the emoji are \xf0\x9f\x86\x93 in the inner code. ";p reg_match_all ('/\xf0.../', $s, $r); foreach ($r [0] as $v) echo current (unpack (' h* ', $v)), Php_eol;
f09f9883
f09f8693
Oh, I'm going to do this with your method.
$text = "This is just the test text \xf0\x9f\x98\x83 in the program, in fact the emoji are \xf0\x9f\x86\x93 in the inner code. ";//callback function call ($matches) {  return" [Emoji] ". Bin2Hex ($matches [0])." [/emoji] ";} Echo preg_replace_callback (            "|\xf0...|",            "call",            $text);
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.