Simple Regex Replace Visual Script
I have the following code
<% 
txt = ""+(rs_email.Fields.Item("g_email_body").Value)+""
Set objReg = CreateObject("vbscript.regexp")
objReg.Pattern = "[activate]"
activate = (objReg.Replace(txt,"http://www.gamtool.com/activate.asp?id="+(Recordset1.Fields.Item("g_userbase_id").Value)+""))
%>
When I run the code I get an error on the last line
activate = (objReg.Replace(txt,"http://www.gamtool.com/activate.asp?id="+(Recordset1.Fields.Item("g_userbase_id").Value)+""))
    %>
any ideas why I am getting the error?
I have updated the code above to the following:
<%
  Set regEx = New RegExp
  regEx.Global = true
  regEx.IgnoreCase = True
  regEx.Pattern = "\[activate\]"
  strText = ""+(rs_email.Fields.Item("g_email_body").Value)+""
  activate = regEx.Replace(strText, ""+(Recordset1.Fields.Item("g_userbase_id").Value)+"")
%>
If I change the ""+(Recordset1.Field开发者_开发知识库s.Item("g_userbase_id").Value)+"") to any value but insert the value static then it works.
Thanks
@Gerald Ferreira: Instead of using +, use & to concatenate. You're getting the type mismatch error because VB Script thinks you're trying to add which, of course, isn't the same as concatenating.
 
         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论