 |
| Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0 |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

May 14th, 2006, 02:07 PM
|
|
Friend of Wrox
|
|
Join Date: May 2005
Posts: 149
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
replace function
The follwing function works
function FixID(str)
FixID = trim(replace(str, "'", ""))
end function
but when I add another fixID to repkace spaces like this
function FixID(str)
FixID = trim(replace(str, "'", ""))
FixID = trim(replace(str, " ", ""))
end function
only the first one works(replace ') but not the second one.
how should I change it so it replaces both!
|
|

May 14th, 2006, 11:55 PM
|
|
Registered User
|
|
Join Date: May 2006
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
that second function is trimming and replacing single quotes in the function argument str THEN it trims and replaces spaces of that versame argument that was passed. you need to do this to an assigned var...not the str on the second replace
Code:
<%
Function FixID(str)
FixID = TRIM(REPLACE(str, "'", ""))
FixID = TRIM(REPLACE(FixID, " ", ""))
End Function
Response.Write FixID("four, score, and, seven, years, ago")
%>
|
|

May 15th, 2006, 12:01 AM
|
|
Registered User
|
|
Join Date: May 2006
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
ooops...the example was supposed to have quotes...not commas
Function FixID(str)
FixID = TRIM(REPLACE(str, "'", ""))
FixID = TRIM(REPLACE(FixID, " ", ""))
End Function
Response.Write FixID("four' score' and' seven' years' ago")
|
|

May 15th, 2006, 12:57 AM
|
|
Friend of Wrox
|
|
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
|
|
Another way to skin the same cat:
Function FixID(str)
FixID = ""
on error resume next
FixID = CStr(str)
if (len(FixID) > 0) Then
FixID = Replace(FixID, "'", "", 1, -1, 1)
FixID = Replace(FixID, " ", "", 1, -1, 1)
end if
End Function
Wind is your friend
Matt
|
|
 |