A string filter problem

Source: Internet
Author: User
This post was last edited by Ruiman on 2014-02-08 11:04:14

PHP string Regular expression

To learn PHP, now encountered a $contents variable inside the content as follows document.write ('
Width= "height=" align= "Absbottom" src= "Other%20web_files/slogo-news.gif"
border= "0" > target= "_blank" > Education News
href= "Http://news.ycwb.com/2014-02/08/content_6034510.htm"
target= "_blank" > Professor Zhang Xingdong elected as foreign academician of the National Academy of Engineering Golden Sheep Net 06:29
href= "Http://news.xinhuanet.com/edu/2014-02/08/c_126099001.htm"
target= "_blank" > Beijing to push a brilliant plan directed to the ecological conservation Area Xinhua 09:11
target= "_blank" > Zhaoqing: 2.21 million passengers in main scenic spots Bright net 08:29
target= "_blank" > to the hometown of nostalgia hidden in the heart of the Spring Festival after the doll with the parents set out photos Xinhua 08:47
href= "Http://news.xinhuanet.com/edu/2014-02/08/c_119240720.htm"
target= "_blank" > What new reform measures to promote the employment of college graduates Xinhua 10:18
target= "_blank" > Leveraging "adaptive learning" Knewton deductive online education reform Sohu 09:55
href= "http://www.sd.xinhuanet.com/news/2014-02/08/c_119235535.htm" target= "_blank" > Shandong for Self-financed study intermediary tighten hoop
Admission to primary and secondary schools is prohibited Xinhua Shandong Channel 08:03
target= "_blank" > Western Han Dynasty "academic Super Man" Planning "Poetry Sutra Show" Take the fame Xinhua 07:04
target= "_blank" > Li's brother put on airs and scolded by subordinates Xinhua 07:04
target= "_blank" > Jiangsu Jintan Education system Work "stick to walk" touch the base vein China Education News Network 08:50

target= "_blank" > More >> ");
Now I want to href= the contents of "http://news.ycwb.com/2014-02/08/content_6034510.htm".
target= "_blank" > Professor Zhang Xingdong elected the U.S. National Academy of Engineering Foreign academician sieve a few out, how should I operate.


Reply to discussion (solution)

What do you mean by "sieve a few"? How is this standard defined?

$STR = "Content";p reg_match_all ("#.* #is", $str, $matches);p Rint_r ($matches);

$STR = "Content";p reg_match_all ("#.* #i", $str, $matches);p Rint_r ($matches);

 $s =<<< txtdocument.write (' Education news professor Zhang Xingdong elected foreign academician of the National Academy of Engineering  Golden Sheep net 06:29  
Beijing pushes a brilliant plan to target ecological conservation zone Xinhua 09:11
Zhaoqing: Main Scenic Area welcomes 2.21 million passengers bright net 08:29
put the heart of the homeland After the Spring Festival, the doll with their parents set of Xinhua 08:47
Promote the employment of college graduates what new reform measures Xinhua 10:18
Leveraging "adaptive learning" Knewton deductive online education reform Sohu 09:55
Shandong for the self-financed study intermediary tighten hoop forbidden to primary and secondary school enrollment Xinhua Shandong Channel 08:03
Western Han "Academic Super Male" planning "Poetry Sutra Show" Take the Fame net 07:04
Li's brother put on airs by subordinates scold net 07:04
Jiangsu Jintan education system Work "stick to walk" touch the basic pulse China Education News Network 08:50
More >> '); txt;//all a Mark Preg_match_all (' # #isU ', $s, $r);p rint_r ($r [0]);//Only a mark of the text title Preg_match_all (' # #isU ', $s, $r);p rint_r ($r [0] Preg_match_all (' # #isU ', $s, $r);p rint_r ($r [0]) that contains only the specified vocabulary;
Array (    [0] =     [1] = + Education News    [2] = Professor Zhang Xingdong elected as a foreign academician of the National Academy of Engineering     [3] = Beijing pushes a brilliant plan to invest in ecological conservation Areas     [4] =& Gt Zhaoqing: The main scenic area welcomes 2.21 million passengers [5] ~ ~ to the    hometown of the hidden Heart after the Spring Festival doll with their parents set     [6] = what new reform measures to promote the employment of college graduates     [7] = "Adaptive learning" Knewton deduction of online education reform    [8] = Shandong for the self-financed study intermediary tighten hoop prohibited to primary and secondary school admissions     [9] = Western Han "Academic Super Male" planning "poetry Show" Take the Fame    [ten] = Li Brother airs by subordinates scold    [One] = Jiangsu Jintan education system Work "stick to walk" touch the basic vein    [[0] + + >>] Array (    [1] = education News [+] = Zhang Xingdong, professor of    the National Academy of Engineering, elected as foreign academician     [2] = Beijing to push a brilliant plan directed to the ecological conservation Area     [3] = = Zhaoqing: The main scenic area welcomes 2.21 million passengers    [4] = = To the hometown of the hidden Heart after the Spring Festival doll with their parents set     [5] = = To promote the employment of college graduates what new reform measures     [6] = "Adaptive learning" Knewton deductive online education transformation    [7] =& Gt Shandong for the self-financed study intermediary tight hoop prohibited to primary and secondary school admissions     [8] and the Western Han "academic Super Male" planning "poetry Show" to take the Fame    [9] = Li's brother airs by subordinates scold    [ten] = Jiangsu Jintan education system Work "stick to walk" Touch the base vein    [one] = more >>) Array (    [0] = Professor Zhang Xingdong elected the National Academy of Engineering Foreign Academician)

Thanks to the moderator's answer, regular expressions have seen, did not expect to be so used, completely solve my problem, know my needs, Master is the master OH

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