Ask how to match a regular expression: & lt; (. *) href [] (. *) [] & gt; & lt; div & nbsp; & gt; & lt; B & gt ;(. *) & lt; B & gt; & lt; div & gt; & lt; a & gt; content: & lt; li & gt; str & lt; li & gt; & lt; li & gt; & lt; a & nbsp; href
Regular expression:
(.*)
Content:
Str
Title 1
Title 2
Target: (must contain
)
Title 2
Current error result: (The entire segment is matched)
Title 1
Title 2
Share:(.*)
Content:
Str... 'Data-pics = ''>
------ Solution --------------------
Add U to prohibit greed
------ Solution --------------------
Is that what it means?
$ Str ='
StrTitle 1Title 2
';
Preg_match_all ("/
(. *) <\/B> <\/p> <\/a>/is ", $ str, $ match );
Echo"
";
print_r($match);
------ Solution --------------------
Give a reminder
To match some boundary content, write regular expressions in the form of boundary + exclusive boundary + boundary to avoid random use of dots.
In particular, html and other markup languages. because the markup language is characterized by a tag, it is also legal to include a line break in the middle, and the dot cannot be covered. if you use a dot, it is a bit of an assumption that the source string must be neat.
For example:
Href ="
Abc/abc.html ">
ABC
This html string is completely legal and does not affect the display of the webpage at all, but the regular expression is required.
"[^"] *"
<[^>] +>
[^ <] *
------ Solution --------------------
$ S = <TXT
StrTitle 1Title 2
TXT;
Preg_match ('/. + ()/is', $ s, $ m );
Echo $ m [1];
Title 2