87,994
社区成员
发帖
与我相关
我的任务
分享
indexof 可以。但是,不可能都这么巧可以用到这个,,
还是感谢上面各位大侠的热心帮助var sql = "anychar select num as 序号,code, as 代码, name as 名称\n"
+"from (select rownum num, t.*"
+"from (select t.code code, t.name name"
+"from table t"
+"order by t.name desc) t"
+"where rownum <= #EndPage#)"
+"where num >= #StartPage#";
sql=sql.replace(/(\n|\r|\n\r)/g,'');
alert(sql.substring(sql.indexOf('select')+7, sql.indexOf('from')));
..我不止前台,后台也要用到正则的,前后台的正则使用方法区别很大。··所以要想句通用正则,就是可以在RegExTester.exe工具上测试的
<script type=text/javascript>
var str = "select num as 序号,code, as 代码, name as 名称\
from (select rownum num, t.*\
from (select t.code code, t.name name\
from table t\
order by t.name desc) t\
where rownum <= #EndPage#)\
where num >= #StartPage#";
//第一:
str.replace(/\bselect\s*(.+?)(?=\r*from\b)/i, function($1, $2){alert($2)});
//第二:
alert(/\bselect\s*(.+?)(?=\r*from\b)/i.test(str) ? RegExp.$1 : "");
//......
</script>
<script type=text/javascript>
var str = "select num as 序号,code, as 代码, name as 名称\
from (select rownum num, t.*\
from (select t.code code, t.name name\
from table t\
order by t.name desc) t\
where rownum <= #EndPage#)\
where num >= #StartPage#";
//第一:
str.replace(/select\s*(.+?)(?=\r*from)/, function($1, $2){alert($2)});
//第二:
alert(/select\s*(.+?)(?=\r*from)/.test(str) ? RegExp.$1 : "");
//......
</script>