ASP Replace character replacement detailed

Source: Internet
Author: User
Tags regular expression

Title=replace (title, "DF", "SD", 1,-1,1)
Replace function parameter detailed:
Parameter 1: source string
Parameter 2: The character to be replaced
Parameter 3: New characters
Parameter 4: value 1, specifies that the string should be searched starting from the first character
Parameter 5: The value is-1 specifies that each substring is to be replaced
Parameter 6: A value of 1 specifies that comparisons of strings are case-insensitive.


Replace in VBScript () Details:

Function: Finds in a string, substituting the specified string.
Format: replace (Strtobesearched,strsearchfor,strreplacewith [, Start[,count[,compare]]])
Parameter: strtobesearched is a string; strSearchFor is the substring being looked for; strReplaceWith is the substring to be substituted. Start,count,compare is any option.

Example:

The code is as follows Copy Code

<%
Strtest= "This is an apple."
Response.Write Replace (strtest, "Apple", "orange")
%>

Instance

The next one is to replace "'" for ""

The code is as follows Copy Code

Function Strreplace (STR)
Dim tempcheckstr
Tempcheckstr=str
If Isnull (TEMPCHECKSTR) Then
Strreplace = ""//here to register, if the string is empty, the replace will be wrong
Exit Function
End If
Strreplace = Replace (Tempcheckstr, "'", "")
End Function


Here is a link to the keyword

The code is as follows Copy Code

function Insertlink (Str,key,url)
If str<> "" Then
Str=replace (Str,key, "<a href=" &url& ">" &key& "</a>"
End If
Insertlink=str
End Function

ASP uses the replace of regular expressions

The code is as follows Copy Code

Set regEx = New RegExp
Regex.pattern = Reg ' Regular expression
Regex.ignorecase = True ' Ignore case
Regex.global = True
Newstr= regex.replace (Oldstr,newpart) ' Reg is replaced with Newpart
Set regEx = Nothing

Replace replace ignore case

Replace (expression, find, replacewith[, start[, count[, compare]]) principle above, count refers to the number of replacements,-1 to replace all

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.