User Tools

Site Tools


substituting_20characters_20in_20a_20string

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

substituting_20characters_20in_20a_20string [2018/03/31 13:19]
127.0.0.1 external edit
substituting_20characters_20in_20a_20string [2018/04/17 19:01]
tbest3112 Added syntax highlighting
Line 2: Line 2:
  
 //by Richard Russell, August 2011//\\ \\  If you want to substitute one character for another in a string (for example you want to change every colon '​**:​**'​ into a dash '​**-**'​) there'​s a more efficient and elegant way than looping through each character in turn:​\\ ​ //by Richard Russell, August 2011//\\ \\  If you want to substitute one character for another in a string (for example you want to change every colon '​**:​**'​ into a dash '​**-**'​) there'​s a more efficient and elegant way than looping through each character in turn:​\\ ​
 +<code bb4w>
         REPEAT         REPEAT
           i% = INSTR(A$,":"​)           i% = INSTR(A$,":"​)
           IF i% MID$(A$,​i%,​1) = "​-"​           IF i% MID$(A$,​i%,​1) = "​-"​
         UNTIL i%=0         UNTIL i%=0
 +</​code>​
 This is particularly efficient in the typical case when not many characters need to be substituted. This is particularly efficient in the typical case when not many characters need to be substituted.
substituting_20characters_20in_20a_20string.txt ยท Last modified: 2018/04/17 19:01 by tbest3112