...

View Full Version : convert a string



sm_mp
02-12-2003, 04:40 PM
can anybody tell me how I can convert or translate a string that is taken from the user. for example when the user enter "abcdefghijkdeflmndefop" I want to read the string character by character and detect "def" anywhere in the string. and return "A" instead of that.

head8k
02-12-2003, 05:30 PM
You can use the Replace function to do this. Get your user's input from a form element and use it like this:

<%
strInput = Request.Form("form_fieldname_name_goes_here")
strInput = Replace(strInput, "def", "A")
Response.Write strInput
%>

whammy
02-13-2003, 02:15 AM
<%
Dim myString
myString = "abcdefghijkdeflmndefop"
myString = Replace(myString,"def","A")
%>

Please be more specific, though, you may want a regular expression function such as these:

http://www.solidscripts.com/displayscript.asp?sid=10



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum