比如[id]2160423[id!][destid]6201777154[destid!]这样一段代码,选取[destid]与[destid!]中间的内容
------解决方案--------------------
<script language= "JavaScript ">
document.write( "[id]2160423[id!][destid]6201777154[destid!] ".replace(/(.*)?\[destid\](.*)?\[destid!\](.*)?/, "$2 "))
</script>
------解决方案--------------------
用Vbscript的话,可以用instr()获得字符位置。再截取。
------解决方案--------------------
Dim str str = "[id]2160423[id!][destid]6201777154[destid!] " Dim reg set reg = new Regexp reg.Pattern = ( "\[destid\](.*?)\[destid\!\] ") reg.IgnoreCase = true Dim ms set ms = reg.Execute(str) if ms.count> 0 then Response.Write ms(0).submatches(0) end if