Help write a regular expression
Alice cos alice dress alice in Wonderland alice crazy back alice flower pot alice hand office alice girl alice school alice Phil alice hand bag alice retro
I want to retrieve
To
Between the title value and the href value in this section, because this format is also available elsewhere on this page, so now you can directly use
$contents_key = '~~';preg_match_all($contents_key,$html,$contentskey);
This will include the same format outside the dd tag. how can I write this regular expression?
Reply to discussion (solution)
In two steps, match the content in the dd label before applying your regular expression.
First
To
And then parse the title and link.
In two steps, match the content in the dd label before applying your regular expression.
However, the dd tag cannot be captured directly.
There are many spaces in the dd tag. I use (.*?) Not matched.
What is the final result you want?
What is the final result you want?
I want title = "here is what I want" href = "here is what I want", and it is best to have a regular expression. I feel that the two regular expressions must match twice, is efficiency a little too low?
$ S = <
Alice cos alice dress alice in Wonderland alice crazy back alice flower pot alice hand office alice girl alice school alice Phil alice hand bag alice retroDafdsafp; preg_match ('/
(. + ?) <\/Dd>/S', $ s, $ m); echo $ m [1];
Alice cos
Alice dress
Alice in Wonderland
Alice crazy regression
Alice pot
Alice hands-on
Alice
Maids
Alice's school
Alice Phil
Alice handbag
Alice Vintage
Try to match the dd content
$pattern = '/
.*<\/dd>/is'
Modifier I: case-insensitive
Modifier s: a "dot" in the pattern will match all characters, including line breaks. without him, line breaks will be excluded. This modifier is equivalent to the/s modifier in Perl.
$contents_key = '~
([\s\S]*?)
~';
I thought about it myself. this is done.