PHP regular expressions in double quotes

Source: Internet
Author: User
Tags regular expression

When writing a program, summarize a little experience, how to take only the data in double quotes of strings

For example: $aihao = ["\u7f8e\u98df", "\U4EA4\U53CB", "\u5176\u4ed6"], take out \U7F8E\U98DF

Preg_match_all ('/\ "(. *?) \ "/", $aihao, $aharr);

echo $aharr [0][0];
echo $aharr [0][1];
echo $aharr [0][2];

The output is: "\U7F8E\U98DF"
"\U4EA4\U53CB"
"\u5176\u4ed6"

Finally, you can use Str_replace ("\" "," ", $aharr [0][0]) to remove double quotes

Example

<li><div class= "Avatar" ></div><div class= "nickname" >alison simple </div></li><li> Who can help me write a regular expression, put forward all nickname value "Alison Simple" I have a better answer.

Code

Preg_match_all ('/<div\s+class= "nickname" > ([^>]*) <\/div>/is ', $String, $Array);
Print_r ($Array);

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.