PHP replacement problem. As long as it is not Chinese, numbers, letters are replaced by--

Source: Internet
Author: User
PHP replacement problem. As long as it is not Chinese, numbers, letters to replace--space,. % replaced by _

For example, this file name??? ??? ?? _trax_full Hd_1080ppc.txt

Replaced by--_--_--_trax_full Hd_1080ppc.txt

I'm using the Str_ireplace function as if it's not possible.
Who helps to write a function to replace non-Chinese, numbers, letters--
And then I'm going to use the following function to return $str should be OK.
return Str_ireplace (Array (', ' & ', ' • ', '% '), ' _ ', $str);


Reply to discussion (solution)

Calculate only half-width of English
Preg_replace (' #[^a-z0-9\x4e00-\x9fcf] #iuU ', '--', $str);

Contains full-width half-width English number
Preg_replace (' #[^a-z0-9\xff10-\xff19\xff21-\xff3a\xff41-\xff5a\x4e00-\x9fcf] #iuU ', '--', $str);
The above-mentioned regular does not contain all Chinese characters, so it may be wrong to kill, but the probability is very low.


\xff10-\xff19 Full Angle 0-9
\XFF21-\XFF3A Full-width A-Z
\XFF41-\XFF5A Full-width A-Z
\X4E00-\X9FCF main Chinese characters (few archaic, allogeneic words not in this range)

Calculate only half-width of English
Preg_replace (' #[^a-z0-9\x4e00-\x9fcf] #iuU ', '--', $str);

Contains full-width half-width English number
Preg_replace (' #[^a-z0-9\xff10-\xff19\xff21-\xff3a\xff41-\xff5a\x4e00-\x9fcf] #iuU ', '--', $str);
The above-mentioned regular does not contain all Chinese characters, so it may be wrong to kill, but the probability is very low.


\xff10-\xff19 Full Angle 0-9
\XFF21-\XFF3A Full-width A-Z
\XFF41-\XFF5A Full-width A-Z
\X4E00-\X9FCF main Chinese characters (few archaic, allogeneic words not in this range)
It doesn't seem like it's going to work, but thank you.

Oh, square brackets plus a + sign, with only the single-character replaced
If it's a mixed-up problem, it's about replacing characters with Chinese characters or English numbers.

Oh, square brackets plus a + sign, with only the single-character replaced
If it's a mixed-up problem, it's about replacing characters with Chinese characters or English numbers.

You can use regular to replace only Korean and special symbols.


Oh, square brackets plus a + sign, with only the single-character replaced
If it's a mixed-up problem, it's about replacing characters with Chinese characters or English numbers.

You can use regular to replace only Korean and special symbols.
It's hard to understand the language you're saying.
Is it possible to use regular to replace only Korean and special symbols?
Is it possible to replace only Korean and special symbols with regular?

Which one does that mean?

The range of Korean is ac00-d7af (main font)
Special symbols are difficult, Unicode contains tens of thousands of symbols, and very scattered, some of which we look at as symbols, but may be the language of a certain nation
For example, many of the symbols of mathematical and physical formulas are ancient Greek
Symbols generally only have a small range of

  • 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.