How should a regular expression match data similar to xf0x9fx91xab?

Source: Internet
Author: User
Tags unpack
How should the regular expression match data similar to xf0x9fx91xab? How should I match the regular expression \ 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. This is only one of them.


$s = "\xf0\x9f\x91\xab";var_dump(preg_match('/\xf0\x9f\x91\xab/', $s));


Then you can only match one. This is only one of them.
Please post all content that needs to be matched !!



$s = "\xf0\x9f\x91\xab";var_dump(preg_match('/\xf0\x9f\x91\xab/', $s));


Then you can only match one. This is only one of them.
Please post all content that needs to be matched !!
For example, Hello, \ xf0 \ x9f \ x98 \ x83. today I am very \ xf0 \ x9f \ x86 \ x93. This binary is uncertain.

If your string is UTF-8, I guess it is correct. \ xf0 \ x9f \ x98 \ x83 and so on are separators. the entire string should have only several forms, each of them should be considered as a single character (no word, only occupying space, separator)
If your string comes from an API, you 'd better check the API documentation.

I have already said this in your other post. Unfortunately, your understanding is too bad.
Rule string: // \ xf0.0 .../

$ S = "this is only the test text \ xf0 \ x9f \ x98 \ x83 in the program. In fact, the emoticons are represented by the internal code \ xf0 \ x9f \ x86 \ x93. "; Preg_match_all ('/\ xf0... /', $ s, $ r); foreach ($ r [0] as $ v) echo current (unpack ('H *', $ v), PHP_EOL;
F09f9883
F09f8693

I have already said this in your other post. Unfortunately, your understanding is too bad.
Rule string: // \ xf0.0 .../

$ S = "this is only the test text \ xf0 \ x9f \ x98 \ x83 in the program. In fact, the emoticons are represented by the internal code \ xf0 \ x9f \ x86 \ x93. "; Preg_match_all ('/\ xf0... /', $ s, $ r); foreach ($ r [0] as $ v) echo current (unpack ('H *', $ v), PHP_EOL;
F09f9883
F09f8693
Well, now I want to implement it using your method.
$ Text = "this is only the test text \ xf0 \ x9f \ x98 \ x83 in the program. In fact, the emoticons are represented by the internal code \ xf0 \ x9f \ x86 \ x93. "; // 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.