Posted: Tue Feb 25, 2003 11:29 pm Post subject: help with string manpulation
can i write a program that inputs a sentence and two characters, the second character should replace the first character in the sentence
i.e Sentence="Computer nerds make millions"
oldchar = "m"
Output should be: Conputer nerds nake nillions
Posted: Wed Feb 26, 2003 2:40 am Post subject: (No subject)
i think that index() returns the position at which it finds the substring, but that wouldn't do us too much good.
so you use stringvariable(index0 to access substrings. Few example to make you understand.
the first value is the start of substring, 2nd is end. Substring is generated between the two values (including them). You can use * instead of using length() function, it does the same thing. And ofcourse you can use math operations and use variables as values for max control.
var text:string := "aaabbbcccaaa"
var textnew:string := ""
if text(i) = "a" then
textnew += "x"
textnew += text(i)
This code reads the string 1 letter at a time and if it finds a letter to replace, it does so. In this case it replaces "a" with "x"