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):
1 2 3 4 5 6 7 |
<% 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):
1 2 3 4 5 6 7 |
<% 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.