ASP Help - editing text string
#1
![Default](https://www.scoobynet.com/images/icons/icon1.gif)
Hi,
I'm passing a text string from a cookie into a text field in a form.
The text is stored as Firstname<space>Surname in the cookie but in order for the field in the form to be valid it needs to appear as Firstname.Surname so that it can form an email address.
Can anyone advise me in simple terms what I need to do to manipulate the text?
Thanks
Rog
I'm passing a text string from a cookie into a text field in a form.
The text is stored as Firstname<space>Surname in the cookie but in order for the field in the form to be valid it needs to appear as Firstname.Surname so that it can form an email address.
Can anyone advise me in simple terms what I need to do to manipulate the text?
Thanks
Rog
#3
Scooby Regular
Join Date: Nov 2001
Location: Leeds - It was 562.4bhp@28psi on Optimax, How much closer to 600 with race fuel and a bigger turbo?
Posts: 15,239
Likes: 0
Received 1 Like
on
1 Post
![Default](https://www.scoobynet.com/images/icons/icon1.gif)
VBScript Replace Function
Returns a string in which a specified substring has been replaced with another substring a specified number of times.
Syntax: VBScript Replace Function
Replace(expression, find, replacewith[, start[, count[, compare]]])
Arguments: VBScript Replace Function
expression
A string expression containing substring to replace. Required.
find
The substring being searched for. Required.
replacewith
The replacement substring. Required.
start
The position within expression where substring search is to begin. If omitted, 1 is assumed. Optional.
count
The number of substring substitutions to perform. If omitted, the default value is -1, which means make all possible substitutions. Optional.
compare
The numeric value indicating the kind of comparison to use when evaluating substrings. See Settings section for values. Optional.
Settings: VBScript Replace Function
The compare argument can have the following values:
Constant
Value
Description
vbBinaryCompare
0
Perform a binary comparison.
vbTextCompare
1
Perform a textual comparison.
Return Values: VBScript Replace Function
Replace returns the following values:
If
Replace returns
expression is zero-length
Zero-length string ("").
expression is Null
An error.
find is zero-length
Copy of expression.
replacewith is zero-length
Copy of expression with all occurrences of find removed.
start > Len(expression)
Zero-length string.
count is 0
Copy of expression.
Remarks: VBScript Replace Function
The return value of the Replace function is a string, with substitutions made, that begins at the position specified by start and concludes at the end of the expression string. It is not a copy of the original string from start to finish.
The following example uses the Replace function to return a string:
Dim MyString
MyString = Replace("XXpXXPXXp", "p", "Y") ' A binary comparison starting at the beginning of the string. Returns "XXYXXPXXY".
MyString = Replace("XXpXXPXXp", "p", "Y", ' A textual comparison starting at position 3. Returns "YXXYXXY". 3, -1, 1)
Returns a string in which a specified substring has been replaced with another substring a specified number of times.
Syntax: VBScript Replace Function
Replace(expression, find, replacewith[, start[, count[, compare]]])
Arguments: VBScript Replace Function
expression
A string expression containing substring to replace. Required.
find
The substring being searched for. Required.
replacewith
The replacement substring. Required.
start
The position within expression where substring search is to begin. If omitted, 1 is assumed. Optional.
count
The number of substring substitutions to perform. If omitted, the default value is -1, which means make all possible substitutions. Optional.
compare
The numeric value indicating the kind of comparison to use when evaluating substrings. See Settings section for values. Optional.
Settings: VBScript Replace Function
The compare argument can have the following values:
Constant
Value
Description
vbBinaryCompare
0
Perform a binary comparison.
vbTextCompare
1
Perform a textual comparison.
Return Values: VBScript Replace Function
Replace returns the following values:
If
Replace returns
expression is zero-length
Zero-length string ("").
expression is Null
An error.
find is zero-length
Copy of expression.
replacewith is zero-length
Copy of expression with all occurrences of find removed.
start > Len(expression)
Zero-length string.
count is 0
Copy of expression.
Remarks: VBScript Replace Function
The return value of the Replace function is a string, with substitutions made, that begins at the position specified by start and concludes at the end of the expression string. It is not a copy of the original string from start to finish.
The following example uses the Replace function to return a string:
Dim MyString
MyString = Replace("XXpXXPXXp", "p", "Y") ' A binary comparison starting at the beginning of the string. Returns "XXYXXPXXY".
MyString = Replace("XXpXXPXXp", "p", "Y", ' A textual comparison starting at position 3. Returns "YXXYXXY". 3, -1, 1)
#4
![Default](https://www.scoobynet.com/images/icons/icon1.gif)
I think I understand the syntax of the REPLACE function but where in my code would I place it?
<input name="Email" type="text" value="<%response.write username%>@company.co.uk"%><%=REPLACE("<%response. write username%>@company.co.uk"," ",".")%> size="40" tabindex="4"><br><br></td>
This is the username variable being pulled from the cookie and an attempt to add the . to replace the <space> between firstname and surname.
Like this, it creates an error.
Can you tell I'm a noob?
<input name="Email" type="text" value="<%response.write username%>@company.co.uk"%><%=REPLACE("<%response. write username%>@company.co.uk"," ",".")%> size="40" tabindex="4"><br><br></td>
This is the username variable being pulled from the cookie and an attempt to add the . to replace the <space> between firstname and surname.
Like this, it creates an error.
Can you tell I'm a noob?
Thread
Thread Starter
Forum
Replies
Last Post
Mattybr5@MB Developments
Full Cars Breaking For Spares
28
28 December 2015 11:07 PM
Mattybr5@MB Developments
Full Cars Breaking For Spares
12
18 November 2015 07:03 AM
hardcoreimpreza
Computer & Technology Related
21
11 October 2015 03:40 PM
alcazar
Computer & Technology Related
2
29 September 2015 07:18 PM