Php regular match string ending with Chinese characters

Source: Internet
Author: User
Php regular expression matches the string ending with Chinese characters. this post is edited by zhuzhaodan at 00:04:00 on.

UTF-8 format
$ Str = "289dfh first matched jdfh388 second matched jfsj83 third matched sjfsui"
1) 289dfh first match
2) jdfh388 second match
3) jfsj83 third match


Reply to discussion (solution)

This post was last edited by xuzuning at 07:05:36 on

$ Str = "289dfh first matched jdfh388 second matched jfsj83 third matched sjfsui "; preg_match_all ('/\ w + [\ x {4e00}-\ x {9fa5}]/iu', $ str, $ r); print_r ($ r [0]);
Array
(
[0] => 289dfh first match
[1] => jdfh388 second match
[2] => jfsj83 third match
)

I want to use Huanshi. the left side does not start with a Chinese character and the right side ends with a Chinese character. how can I write this?

   

You mean this?
You can simply use the negative order ring ~~~

I want to use Huanshi. the left side does not start with a Chinese character and the right side ends with a Chinese character. how can I write this?

This is a black list. The range is too large. you should use a white list to specify what begins

    

You mean this?
You can simply use the negative order ring ~~~

Why is an error reported when I remove the ending/iu?
Compilation failed: character value in \ x {...} sequence is too large at offset 8

/Iu

I indicates case-insensitive
Utable utf8

/Iu

I indicates case-insensitive
Utable utf8

Remove the U and an error is displayed. why is it wrong if U is not specified?

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.