Try regular expression! 100 classification tape

Source: Internet
Author: User
Try a regular expression !! Urgent! 100 classification with a connection similar to this: & lt; a & nbsp; & nbsp; find a regular expression and try it !! Urgent! 100 classification tape
A connection like this:
Href = "http: // url" target = "_ blank"> title
Or
Href = "http: // url"> title
And so on:
I need to use preg_match_all to get a url and a title. array.
Waiting. hope to enlighten me. score immediately


------ Solution --------------------
#] + Href = (['\ "]?) (. +) \ 1 [^>] *> (. *) <\/a> # isU
------ Solution --------------------
Preg_match_all ('/] + href [\ s \ r \ n] * = [\ s \ r \ n] * ([' \ "]?) (. +) \ 1 [^>] *> (. +) <\/a>/isU ', $ text, $ matches );

------ Solution --------------------
@ Href = "(. *)". *> (.*)
Example:

$ Str = < Href = "http: // url" target = "_ blank"> title
Or

Href = "http: // url"> title
EOF;

Preg_match_all ("@ href = \" (. *) \ ". *> (.*)
Print_r ('
');
Print_r ($ matches );
?>
Output:
Array
(
[0] => Array
(
[0] => href = "http: // url" target = "_ blank"> title [1] => href = "http: // url"> title )

[1] => Array
(
[0] => http: // url
[1] => http: // url
)

[2] => Array
(
[0] => title
[1] => title
)

)

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.