Replace part of a string

Using the Mid function you can remove a section from the middle of a string . The syntax of this function is

Mid (string , position , no_of_chars )

string is our string of text , position is the position of the first character in the string you wish to remove and the third parameter is the number of characters .

Lets see an example

<%
'our string
strText = "Thisisasillylongsentence"
'we wish to keep the word long so we start at character 13
'and then keep 4 characters like this
strNewText = Mid(strText , 13 , 4)
'display the word long
Response.Write strNewText
%>

 

Sponsors