Javascript使用正则表达式替换的问题

来源:百度知道 编辑:UC知道 时间:2024/04/28 06:14:13
我想把col1+col2+col3*col4-col5/col6...+colN替换成
parseInt(document.form1.col1.value)+parseInt(document.form1.col2.value)+parseInt(document.form1.col3.value)+parseInt(document.form1.col2.value)....
这样的怎么写?

问题描述不清楚,不知道是不是这样?

<%
Function ReplaceExp(srcstr, patrn, replStr)
Set regEx = New RegExp
regEx.Pattern = patrn
regEx.IgnoreCase = True
regEx.Global = True
regEx.Execute(srcstr)
ReplaceExp = regEx.Replace(srcstr, replStr)
Set regEx = Nothing
End Function
NewStr = ReplaceExp(OldStr, "/(col\d+)[\+\-\*\/](col\d+)/", "$1+$2")
NewStr = ReplaceExp(NewStr, "/col(\d)+/", "parseInt(document.form1.col$1.value)")
%>

不会