js完成的提取网页信息

public static void pattern(){
		String str="<h1><a class='deal-today-link' href='  http://www.meituan.com/beijing/deal/shuangta.html'>今日团购:</a>仅售48元!价值160元的双塔采摘园葡萄节双人行(可带1名儿童),采摘+垂钓+烧烤,吃不了可以“兜”着走!</h1>";
		String part1;
		String part2;
		String pattern="<h1><a[^<>]*>(.*)</a>(.*)</h1>";
		
		Pattern p=Pattern.compile(pattern);   
		Matcher m = p.matcher(str); 
		while(m.find()){
			part1 = m.group(1).trim();   
            part2 = m.group(2).trim();   
            System.out.println(part1+","+part2);  
		}
	}


如果用js的话
script type="text/javascript">     
          function testjs()
          {
            var p=/<a[^<>]*>(.*?)<\/a>/;
            var str="<a class='deal-today-link' href='33'>大家好</a>";
           var str1=str.replace(p,"$1");
             //var str2=str.replace(p,"$1");
            alert(str1);
           }
        </script>

你可能感兴趣的:(JavaScript,java)