I ran across a problem this weekend working with the regexp object. Since I do most of my programming in perl, reg expressions are not new to me. But ASP gave me some problems.
I had a string...actually a path on my drive...
example:
e:\mike.com\templates\foo.asp
This became my string:
I was looking for a pattern in the string:
pattern="e:\mike.com\templates\"
I wanted to replace that pattern with nothing, so I could get foo.asp.
I was getting some error when trying to use .replace...
I had something like this:
*****************************************
dim re, string
set re=new regexp
string="e:\mike.com\templates\foo.asp"
re.pattern="e:\mike.com\templates\"
if re.test(string) then
re.replace(string, ""
end if
*****************************************
I was getting some error that said the parenthesis shouldn't be used for replace...So I got rid of them, though all documentation told me to have them. Then I tried without the (). It said replace was not a valid method, or something like that. Does anyone know what the deal was?
I actually decided to go a different way and create a filesystemobject to grab the file's name. But I don't understand why the pattern replace didn't work. I am using IE 6.0 now.
I'd love to hear if anyone knows the deal behind this.
Mike
I had a string...actually a path on my drive...
example:
e:\mike.com\templates\foo.asp
This became my string:
I was looking for a pattern in the string:
pattern="e:\mike.com\templates\"
I wanted to replace that pattern with nothing, so I could get foo.asp.
I was getting some error when trying to use .replace...
I had something like this:
*****************************************
dim re, string
set re=new regexp
string="e:\mike.com\templates\foo.asp"
re.pattern="e:\mike.com\templates\"
if re.test(string) then
re.replace(string, ""
end if
*****************************************
I was getting some error that said the parenthesis shouldn't be used for replace...So I got rid of them, though all documentation told me to have them. Then I tried without the (). It said replace was not a valid method, or something like that. Does anyone know what the deal was?
I actually decided to go a different way and create a filesystemobject to grab the file's name. But I don't understand why the pattern replace didn't work. I am using IE 6.0 now.
I'd love to hear if anyone knows the deal behind this.
Mike