Questions about PHP regular expressions that you cannot understand

Source: Internet
Author: User
PHP regular expression (code) $ str = & lt; EODHTML... & lt; objectwidth = & quot; 425 & quot; height = & quot; 350 & quot; & gt; & lt; paramname = & q do not want to understand the PHP regular expression
[Code]
$ Str = < HTML...




HTML...
EOD;

$ Reg1 = '/ ] *> (.(?! $ Reg2 = '/ | [^>] +>)/S ';
$ Reg3 = '/ ] *> (.(?! | [^>] +>)/S ';

Preg_match ($ reg1, $ str, $ out1 );
Preg_match ($ reg2, $ str, $ out2 );
Preg_match ($ reg3, $ str, $ out3 );

Echo "$ str \ n
";
Print_r ($ out1 );
Print_r ($ out2 );
Print_r ($ out3 );



[Output]
HTML...




HTML...



Array
(
[0] =>

[1] =>
)
Array
(
[0] =>
[1] => src = "http://www.atungm.com/v/AyPzM5WK8ys" type = "application/x-shockwave-flash" wmode = "transparent" width = "425" height = "350">
)
Array
(
)



[Problem]
Regular expression 1 and regular expression 2 match the first and second parts of the target string accurately and completely;
Regular Expression 3 is the integration of regular expression 1 and regular expression 2, but there is a problem and the content cannot be matched;
After trying for a long time, I cannot find any conflict between regular expression 1 and regular expression 2?

I only had 14 resource points, so I gave them all.
I don't know which expert can provide guidance?

------ Solution --------------------
$ Reg3 = '/ ] *> (.(?! | [^>] +>)/S ';

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.