作为字符串来操作吗?这里是用脚本实现的例子
<script language="javascript">
<!--
  var reg1, reg2;
  var html_str = '<tr><td width="100%" bgcolor="#e5e5e5"><p align="center"><input style="width: 269px; height: 22px" maxlength="350" size="50" name="key"></td></tr>';
  alert('html_str='+html_str);
  
  reg1 = /<tr>/gi;
  reg2 = /<\/tr>/gi;
  new_html_str = html_str.replace(reg1, '').replace(reg2, '');
  alert('new_html_str='+new_html_str);
-->
</script>

解决方案 »

  1.   

    package net.v246;
    import java.util.regex.*;
    import java.io.*;
    public class Test
    {
    public static void main(String[] args)
    {
    File f = null;
    FileInputStream in = null;
    InputStreamReader r = null;
    java.io.BufferedReader read = null;
    try
    {
    f = new File("c:/Test.txt");
    in = new FileInputStream(f);

    r = new InputStreamReader(in);
    read = new BufferedReader(r);
    StringBuffer s = new StringBuffer(1024*3);
    String tmp = null;
    while((tmp=read.readLine())!=null)
    {
    s.append(tmp);
    }
    //System.out.println(s);
    String rule = "<tr>[\\W*\\w]*</tr>";

    Pattern p = Pattern.compile(rule);
    java.util.regex.Matcher m = p.matcher(s.toString());
    int x = 0;
    while(m.find())
    {
    System.out.println("x=============================="+(++x));
    System.out.println(m.group());
    }
    }
    catch(Exception e)
    {

    e.printStackTrace();
    }
    finally
    {
    try
    {
    if(read!=null)read.close();
    if(r!=null)r.close();
    if(in!=null)in.close();
    }
    catch(Exception e)
    {
    if(read!=null)read.close();
    if(r!=null)r.close();
    if(in!=null)in.close();
    }
    }
    }
    }其中Test.txt里存的就是你上面的那一大段要分析东东!经过测试!分来。。
      

  2.   

    String rule = "<tr>[\\W*\\w]*</tr>";为了保险,应该换成:String rule = "<tr>[\\W*\\w*]*</tr>";不好意思,没考虑周到
      

  3.   

    var str = "<tr><td>sdfdsfs</td>\n<td>sdfasdfasdfas</td></tr>";//代表你要匹配的字符串
    var reg = /<tr>((\n|\r|.)*?)<\/tr>/mi;//regex ,m--代表多行, i--不分大小写
    var arr = str.match(reg);            //匹配,返回一个数组
    var result = arr[1];                 //第二个就是你要的结果
    alert(result);