Php regular expression matching string ending with Chinese characters

Source: Internet
Author: User
Tags php regular expression
Php regular match string ending with Chinese characters This post was last edited by zhuzhaodan in 2013-06-0900: 04: 00 UTF-8 format $ str & nbsp; 289dfh first match & nbsp; & nbsp; jdfh388 second match & nbsp; jfsj83 third match & nbsp; sjf php regular match string ending with Chinese characters

This post was last 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

Share:


------ 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
)

------ Solution --------------------
 $ Str = "289dfh: The first matches jdfh388, the second matches jfsj83, and the third matches sjfsui. do not use haha ";
Preg_match_all ('/\ s *(?! [\ X {4e00}-\ x {9fa5}]) \ w + [\ x {4e00}-\ x {9fa5}] +/iu ', $ str, $ r );
Print_r ($ r [0]);


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

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.