Questions about regular expression matching

Source: Internet
Author: User
Tags preg
Obtain the matched characters in the Href attribute of A tag. For more information, see <divclass = & quot; a & quot; herf = & quot; regular match.
Obtain the Href attribute of A tag

Matched characters

Connection 1
Connection 2
Connection 3


You can use single quotes without quotation marks, but you cannot use either of them.

PHP code
  preg_match('//i', $str, $matches)



Why not?

------ Solution --------------------
PHP code
$ Str = <
  
   
] *>/', $ Str, $ matches); print_r ($ matches [2]);
   
------ Solution --------------------
PHP code
$ Str = <
     ------ Solution --------------------
PHP code
[User: root Time: 14: 14: 52 Path:/home/liangdong/php] $ php preg. php Array ([0] => Array ([0] => Array ([0] => "[1] => '[2] =>) [2] => Array ([0] => http://www.baidu.com/[1] => http://www.baidu.com/[2] => http://www.baidu.com/) [User: root Time: 14: 14: 53 Path:/home/liangdong/php] $ cat preg. php
       

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.