How to use php to intercept a specific paragraph

Source: Internet
Author: User
Php intercepts a specific paragraph how to operate such as the user input a string of characters through the text box the first input content: $ w1 = "& nbsp; http://you.video.sina.com.cn/ B /25323843-1272884840.html"; the second input content: $ w2 = php: how to intercept a specific section
For example, you can enter a string of characters in the text box.
Content entered for the first time: $ w1 = "http://you.video.sina.com.cn/ B /25323843-1272884840.html ";
Second input: $ w2 = "http://v.youku.com/v_show/id_XMzIzNjA2NjE2.html ";


First result: $ val = "25323843 ";
The second result: $ val = "XMzIzNjA2NjE2 ";

Assuming that the above two values are entered by the user separately, how does the program automatically extract the values I need? Can you give an example?


Could you please help me to share with us:
------ Solution --------------------

// Video link processing
Function url_1 ($ str)
{
$ Ubb_search = array ("/http: \// \/(v
------ Solution --------------------
Www) .youku.com \/v_show \/id _ (. + ?). Html/I ", // 1
"/Http: \/v.ku6.com \/show \/(. + ?). Html/I ", // 2
"/Http: \// www.tudou.com \/programs \/view \/(. + ?) \ // I ", // 3
"/Http: \/you.video.sina.com.cn \/B \/(. + ?) -(. + ?). Html/I ", // 4
"/Http: \/(. + ?). Joy.cn \/video \/(. + ?). Htm/I ", // 5
"/Http: \/www.openv.com \/play \/(. + ?). Html/I ", // 6
"/Http: \/video.pomoho.com \/ent \/(. + ?) /I ", // 7
"/Http: \/www.weplay.cn \/c2 \/(. + ?). Html/I ", // 8
"/Http: \/v.blog.sohu.com \/u \/vw \/(. + ?) /I ", // 9
// "/Http: \/vlog.17173.com \/v \/(. + ?) \/(. + ?) \/(. + ?) \/(. + ?) /I ", // 10
"/Http: \/www.letv.com \/ptv \/vplay \/(. + ?) /I ", // 11
"/Http: \/TV .mofile.com \/([^ \ [\ <\ r \ n] + ?) \ // I ", // 12
"/Http: \/www.boosj.com \/(. + ?). Html/I ", // 13
"/Http: \ // www.bobmy.com \/FlvMovie \/VIEW (. + ?). Html/I ", // 14
"/Http: \/v.xgo.com.cn \/(. + ?) \/(. + ?). Html/I ", // 15
"/Http: \/play. hupo. TV \/(. + ?). Html/", // 16
"/Http: \/www.nnbbaa.com \/player. php \? Id = (. + ?) /", // 16
"/Http: \/mv.2u.com.cn \/detail _ (. + ?). Html/", // 18
"/Http: \/vsearch.cctv.com \/plgs_play-(. + ?). Html/", // 19
);
$ Ubb_replace = array ("", // 1

);
$ Str_1 = preg_replace ($ ubb_search, $ ubb_replace, $ str );


If ($ str! = $ Str_1 ){
$ Str = 'Recommendation :';}
Else {
$ Str = '';
}
Return $ str;
}





For reference
------ Solution --------------------
$w1=" http://you.video.sina.com.cn/b/25323843-1272884840.html";
$w2="http://v.youku.com/v_show/id_XMzIzNjA2NjE2.html";
preg_match('/\/(\d+)-/',$w1,$m1);
preg_match('/id_(.+?)\./',$w2,$m2);
echo $m1[1];
echo '
';
echo $m2[1];

25323843
XMzIzNjA2NjE2

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.