Replace
The Replace function will replace occurances of
one character string with another. The parameters for this
function are the string you want to do the replacement for,
the string to find and the string to replace it with.
This function is ideal for substituting one text string for
another. You should be careful about which strings will be
replaced so that you don't accidentally replace strings that
you didn't intend to.
Dim sText sText = "It's a Cat's Life" Response.Write "Before: " & sText & "<BR>" sText = Replace(sText, "Cat", "Dog") Response.Write "After: " & sText & "<BR>"
The fourth parameter defines what type of comparison should be
done for matching strings. The only two possible values are to
do a binary comparison (case-sensative matching) or a textual
comparison (case-insensative matching). By default, ASP will
use binary comparison.
Dim sText sText = "It's a Cat's Life" sText = Replace(sText, "cat", "dog") Response.Write "Binary Replace: " & sText & "<BR>" sText = Replace(sText, "cat", "dog", vbTextCompare) Response.Write "Textual Replace: " & sText & "<BR>"
For a more powerful method of doing string searching and
replacement, you should refer to the object reference section
about the RegExp object.
|
 |

|