How does the regular match the content before and after the line break?

Source: Internet
Author: User
Tags preg
A copy of the existing data for:

已建成的电信管道、电信杆路、通信铁塔等电信设施的电信业务经营者应当将空余资源以(  )等方式向有需求的其他电信业务经营者开放。A.出租 2借款B.出售C.资源互换D.抵押E.质押

The result I need to get from the inside is:

1、A.出租 2借款2、B.出售3、C.资源互换4、D.抵押5、E.质押

The difficulty I encountered was:

5, E.
Pledge

In this case, this I want to take out to become: "5, E. Pledge"; instead of needing that line change ~
The result is ("A.") To "B." ), ("B.") To "C." )... And so on the data

============================
According to the first floor, I now put my entire PHP paste out of it.

    //拆分选项列表    public function datalist($data){        $preg = '/[A-E]\.\s?.*[\w\W]?/';        preg_match_all($preg,$data,$results);        foreach($results[0] as $data){            $result[] = trim($data);        }           return $result;    }

Already resolved, thank you all.
Actually very simple, but just can't think out, alas ~:
[A-E]. [^b-e]*

This issue has been closed due to:

Reply content:

A copy of the existing data for:

已建成的电信管道、电信杆路、通信铁塔等电信设施的电信业务经营者应当将空余资源以(  )等方式向有需求的其他电信业务经营者开放。A.出租 2借款B.出售C.资源互换D.抵押E.质押

The result I need to get from the inside is:

1、A.出租 2借款2、B.出售3、C.资源互换4、D.抵押5、E.质押

The difficulty I encountered was:

5, E.
Pledge

In this case, this I want to take out to become: "5, E. Pledge"; instead of needing that line change ~
The result is ("A.") To "B." ), ("B.") To "C." )... And so on the data

============================
According to the first floor, I now put my entire PHP paste out of it.

    //拆分选项列表    public function datalist($data){        $preg = '/[A-E]\.\s?.*[\w\W]?/';        preg_match_all($preg,$data,$results);        foreach($results[0] as $data){            $result[] = trim($data);        }           return $result;    }

Already resolved, thank you all.
Actually very simple, but just can't think out, alas ~:
[A-E]. [^b-e]*

You send the regular you write and see that there's a greedy pattern in the regular.

  • 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.