View Full Version : convert a string
sm_mp
02-12-2003, 03:38 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.
Danne
02-12-2003, 03:50 PM
If you want to get "def", you can use
str.indexOf("def");
and if you want to read the string character by character, you can use
var i;
for(i=0;i<string.length;i++)
alert(str.charAt(i));
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.