Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to use php+ rules to separate alphanumeric and Chinese characters in a string

Shulou Source: shulou.com Published: 2022-06-02 03:42:53 10月05日 Update

This article is about how to use php+ rules to separate alphanumeric and Chinese characters in a string. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

For example: $str= "how does php divide the alphanumeric sf f45d and Chinese _ in the string?" ; divide by number or letter.

$str = "how does php separate alphanumeric Asf f45d and Chinese _ in a string?" ; $arr = preg_split ("/ ([a-zA-Z0-9] +) /", $str, 0, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE); print_r ($arr)

Result

$new = array (); $new [0] = "php"; $new [1] = "how to put in a string"; $new [2] = "322"; $new [3] = "alphanumeric"; $new [4] = "sf"; $new [5] = ""; $new [6] = "f45d"; $new [7] = "and Chinese _ segmentation?" Thank you for your reading! This is the end of this article on "how to use php+ rules to segment alphanumeric and Chinese characters in a string. I hope the above content can be of some help to you, so that you can learn more knowledge. If you think the article is good, you can share it out for more people to see!"

Tags: Letters numbers Chinese characters strings regular content more articles good practical articles see knowledge results references help related Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL OPPO Reno NVidia Apple Redmi