PHP regular expression matching

Source: Internet
Author: User
Tags php regular expression
{Code ...} this is a function for converting a full-width symbol to a half-width symbol found on the Internet. it is valid when used. The principle is that the second byte of Chinese punctuation minus 0X80 (that is, 128) the resulting number is the half-width number, but it still does not meet my needs. what I want is to include...

  

This is a function for converting a full-width symbol to a half-width symbol found on the Internet. it is valid when used. The principle is that the second byte of Chinese punctuation minus 0X80 (that is, 128) the resulting number is the half-width number, but it still does not meet my needs. I want to convert the full-width symbol into a half-width symbol from a piece of text without converting the text.

For example:

Original article: If I cannot protect the most important people around me, what is the significance of my role as a demon.
If I cannot protect the most important people around me, what is the significance of my role as a demon.

How can this be matched ???

It is also necessary to convert the strings in the text into an array. for example, if the array is used, it is converted into a half-width corner and then the text is formed.


  

Reply content:

   

This is a function for converting a full-width symbol to a half-width symbol found on the Internet. it is valid when used. The principle is that the second byte of Chinese punctuation minus 0X80 (that is, 128) the resulting number is the half-width number, but it still does not meet my needs. I want to convert the full-width symbol into a half-width symbol from a piece of text without converting the text.

For example:

Original article: If I cannot protect the most important people around me, what is the significance of my role as a demon.
If I cannot protect the most important people around me, what is the significance of my role as a demon.

How can this be matched ???

It is also necessary to convert the strings in the text into an array. for example, if the array is used, it is converted into a half-width corner and then the text is formed.


   

Your method is good, but it's complicated. look at me.

$ Arr1 = ["1", "2", "3", "A", "B", "C", "D", "F", "W ", "S ","\",""",",",". ","? "," <","> "," {","} "," [","] "," * "," & "," ^ ", "% ","#","@","! ","~ "," (",") "," + ","-"," | ",":",";",". "]; $ Arr2 = [" 1 "," 2 "," 3 "," A "," B "," C "," D "," F ", "W", "S ","\\","\"",",",". ","? "," <","> "," {","} "," [","] "," * "," & "," ^ ", "% ","#","@","! ","~ "," (",") "," + ","-"," | ",":",";",". "]; $ Str =" if I cannot protect the most important people around me, what is the significance of my role as a demon. "; Echo $ str ."
"; For ($ I = 0; $ I

Running result

If I cannot protect the most important people around me, what is the significance of my role as a demon. If I cannot protect the most important people around me, what is the significance of my role as a demon.

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.