Regex matches and returns a line break.

Source: Internet
Author: User
Regex matches and returns a line break. This post was last edited by liuser_cn at 20:51:54

Regular PHP JavaScript HTML


$pattern_Title =   "/target=\"\_blank\"\>.*\<\/a\>s+\<\/h4\>/is";//。。。。


Catch this 'php ';

PHP


Reply to discussion (solution)

\ S is written as s

$pattern_Title =   "/target=\"\_blank\"\>.*\<\/a\>\s+\<\/h4\>/is";

In fact, this is better.
$ Pattern_Title = "/target = \" \ _ blank \ "\>. * \ <\/a \> [\ s \ S] * \ <\/h4 \>/is ";//....

\ S is written as s

$pattern_Title =   "/target=\"\_blank\"\>.*\<\/a\>\s+\<\/h4\>/is";

This is probably not the reason. \ s is frequently used.


$ Pattern_Title = "/target = \" \ _ blank \ "\> \ s * (\ S *) \ s * \ <\/a \> \ s * \ <\/h4 \>/I "; // title
Simplify high-quality regular expressions --!

In fact, this is better.
$ Pattern_Title = "/target = \" \ _ blank \ "\>. * \ <\/a \> [\ s \ S] * \ <\/h4 \>/is ";//....

Q: After modifier s is used, it will not be able to catch low. for example, if I want to end it here, what should I use to declare it?

$s =<<< TXT                     PHP                         TXT;$pattern_Title = '#target="_blank">(.*)\s+#is';preg_match_all($pattern_Title, $s, $r);print_r($r);
Array
(
[0] => Array
(
[0] => target = "_ blank">

PHP



)

[1] => Array
(
[0] =>

PHP

)

)

$pattern_Title = '#target="_blank">\s*(.*)\s*#is';preg_match_all($pattern_Title, $s, $r);print_r($r);
Array
(
[0] => Array
(
[0] => target = "_ blank">

PHP

)

[1] => Array
(
[0] => PHP

)

)

In fact, this is better.
$ Pattern_Title = "/target = \" \ _ blank \ "\>. * \ <\/a \> [\ s \ S] * \ <\/h4 \>/is ";//....

$s =<<< TXT                     PHP                         TXT;$pattern_Title = '#target="_blank">(.*)\s+#is';preg_match_all($pattern_Title, $s, $r);print_r($r);
Array
(
[0] => Array
(
[0] => target = "_ blank">

PHP



)

[1] => Array
(
[0] =>

PHP

)

)

\ S is written as s
$pattern_Title =   "/target=\"\_blank\"\>.*\<\/a\>\s+\<\/h4\>/is";


Thank you!

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.