Removing some letters of a string - Printable Version +- SphereCommunity (https://forum.spherecommunity.net) +-- Forum: Sphere 0.56d (/Forum-Sphere-0-56d) +--- Forum: Script Help (/Forum-Script-Help) +--- Thread: Removing some letters of a string (/Thread-Removing-some-letters-of-a-string) |
Removing some letters of a string - Gil Amarth - 02-26-2013 08:38 AM I´m working in a script which removes some randoms letter of a string. If I have a string like: "I like my blue umbrella", How can I remove some letters from this string? For example, if my randoms are 4,6,11, the string should be: "I l k my lue umbrella", the removed letters should show blank spaces. Any idea how to do this? RE: Removing some letters of a string - RanXerox - 02-26-2013 09:01 AM Check out this wiki chapter on string manipulation: http://wiki.sphere.torfo.org/index.php/Chapter_10 RE: Removing some letters of a string - Gil Amarth - 02-26-2013 09:32 PM Yes, I have manipulated strings a lot, but I don´t have idea how to do this. I can use STRSUB to get a letter in a string, but I don´t know if is it possible to set a letter in a string. So my question. RE: Removing some letters of a string - Norlack - 02-27-2013 02:46 AM well, if you cannot put random blankspaces in a string, do the opposite and write a new string picking just some letters from the previous one. A simple loop can do the job. ^^ RE: Removing some letters of a string - Ultima One - 02-27-2013 03:39 AM I would do the following: generate a random number between 0 and string length-1. get a substring of the random number. Store that somewhere. then get a random number between last random number + 1 and string length-1. get a substring of random number + 1 -> new random. and concatenante that to the last stored substring. repeat that step again and you will have joined 3 substrings, which should have cut off 1 character following the value of the random number that was picked. if that makes sense RE: Removing some letters of a string - Gil Amarth - 02-27-2013 07:12 PM Humm, thats is a good idea. I´ll try that. |