String str = "1,这里是数据\"data1 is here\",这里是数据2^hello.php?x1=11&x2=22,这里是数据2^bye.php?x3=33&x4=44,1,2,3省略";需要一个正则过滤^hello.php?x1=11&x2=22和^bye.php?x3=33&x4=44
对正则不大懂,请教大牛,想写一个过滤的"^*,"替换成","
请教大牛!求助!我写的最后结果成了 3,省略崩溃

解决方案 »

  1.   

    rule
    "\^[^,]+"
    replace
    ""
      

  2.   

    what are you talking about?
      

  3.   

    过滤上面str中的^hello.php?x1=11&x2=22和^bye.php?x3=33&x4=44

    "1,这里是数据\"data1 is here\",这里是数据2^hello.php?x1=11&x2=22,这里是数据2^bye.php?x3=33&x4=44,1,2,3省略";
    得到
    "1,这里是数据\"data1 is here\",这里是数据2,这里是数据,1,2,3省略";
    这样的结果
      

  4.   


    var str="1,这里是数据\"data1 is here\",这里是数据2^hello.php?x1=11&x2=22,这里是数据2^bye.php?x3=33&x4=44,1,2,3省略";
    str=str.replace(/\^\w+\.php\?(\w+=\w+&)*(\w+=\w+)?/g,"");
    alert(str)
      

  5.   

    估计楼主是需要正则的非贪婪模式 <script type="text/javascript">
    <!--
    var str="1,这里是数据\"data1 is here\",这里是数据2^hello.php?x1=11&x2=22,这里是数据2^bye.php?x3=33&x4=44,1,2,3省略";
    str=str.replace(/\^.*?,/g,",");
    alert(str)
    //-->
    </script>
      

  6.   

    try...<script type="text/javascript"> 
    var test = "1,这里是数据\"data1 is here\",这里是数据2^hello.php?x1=11&x2=22,这里是数据2^bye.php?x3=33&x4=44,1,2,3省略";
    var reg = /\^[^^,]*/g;
    var result = test.replace(reg, "");
    document.write(result);
    </script>