String Replace in Classic ASP!

Just like PHP there are some very good in-build functions also there in Classic ASP. Today we are going to see how to replace a string in Classic ASP.

If you are a PHP programmer, you should know str_replace();

Likewise in Classic ASP it is Replace();

Lets start a simple replace example (replace a single character):

<%

origtext    = "mummy"
replacetext = Replace(origtext,"u","o")
print "mummy becomes "&replacetext

%>

Output:
mummy becomes mommy

 

Another example of how to replace a string (replace entire string):

<%

origtext    = "I want to buy a Bike"
replacetext = Replace(origtext,"Bike","Car")
print replacetext

%>

Output:
I want to buy a Car

I hope this example is pretty well for you to understand the string replace function in Classic ASP.

 

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top