Help write a regular expression

Source: Internet
Author: User
 
  
  
Alice cos Alice dress Alice in Wonderland Alice Crazy return Alice Flower Pot Alice hands-on Alice maid Alice Park Alice Phil Alice hand bag Alice Retro-Love-Alice-Alice

I'm going to take this page now.
to the
The value of the title in this section and the value of the HREF, because the page has this format elsewhere, so it is now used directly
$contents _key = ' ~ ';p reg_match_all ($contents _key, $html, $contentskey);
This will include the DD tag in the same format as well, ask how this regular should be written?


Reply to discussion (solution)

In two steps, we first match the contents of the DD tag and apply your regular.

First put

to the
Between the grab to go out and then to parse inside the title and link

In two steps, we first match the contents of the DD tag and apply your regular.
But now the direct crawl of the DD tag is also not captured

There are many spaces in the middle of the DD tag, which I can't match with (. *?).

What is the end result you want?

What is the end result you want?
I want to title= "Here is what I want" href= "here is what I want", and it is best to be a regular, feel two regular to match two times, efficiency is not a bit too low?

$s =<< Alice                                                   cos                            alice dress Alice in                            Wonderland                            Alice Crazy return                            Alice Flower pot Alice Hands-on Alice                            maid Alice                            School Park                            Alice Phil Alice                            hand bag                            Alice Retro                        Dafdsafdiv;preg_match ('/
 
  
  
(. +?) <\/dd>/s ', $s, $m); echo $m [1];


Alice Cos
Alice dress
Alice in Wonderland
Alice's crazy comeback
Alice Flower Pot
Alice hands
Alice
Maid
Alice Learning Park
Alice Phil
Alice Hand Bag
Alice Retro

Try this match for DD content

$pattern = '/
 
  
  
. *<\/dd>/is '

Modifier I: not case
Modifier s: A "point" in the pattern will match all characters, including line breaks. Without him, the change would be ruled out. This modifier is equivalent to the/s modifier in Perl

$contents _key = ' ~
 
  
  
([\s\s]*?)
~';

I thought of it myself, this is done.
  • 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.