Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASP Regexp issue

Status
Not open for further replies.

cajedi

Programmer
Dec 6, 2006
1
0
0
US
I'm experiencing a rather strange issue when i try to use the Regexp object in an ASP script; maybe i'm missing something. basically, i have a script which reads in the contents of a text file, looks for this string pattern "<!---start-->.*<!---end-->" and replaces it with the new employee name like this:
<!---begin-->NEW-EMPNAME<!---end-->. here's the code
'===========================================
Dim REObj
Set REObj = New RegExp

With REObj
.Pattern = "<!---start-->.*<!---end-->"
.IgnoreCase = true
.Global = true
End With

strdata = REObj.Replace(strdata,"<!---begin-->" & strnewemployee & "<!---end-->")

'===========================================
problem is, if the new emp name is something like "empname 2", the final output is coming out as "empname 2 2" (see the duplicate 2 at the end)

if the original data is "empname 2 2", then the script returns "empname 2 2 2". I cant quite see where the problem is. any help would be greatly appreciated
 
Cannot reproduce the problem. In any case, change at least this.
> .Pattern = "<!---start-->.*<!---end-->"
[tt] .Pattern = "<!---start-->.*[blue]?[/blue]<!---end-->"[/tt]
 
With your posted code there should be no way it is coming out wrong unles you are altering the strnewemployee string. Your specifying texactly what should come out, so there is no way you should be keeping anything from the previous entry: "<!---begin-->" & strnewemployee & "<!---end-->"

The only caveat to that is if you have a $ in your employee name with a number after it (or is it backslash for VB...sorry, too many languages recently).

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top