Substring: Difference between revisions

Applesoft BASIC
(→‎{{header|BQN}}: Mention performance)
(Applesoft BASIC)
Line 1,172:
</pre>
 
==={{header|Applesoft BASIC}}===
<lang basic>0 READ N, M, S$ : L = LEN(S$) : GOSUB 1 : END : DATA 5,11,THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG,J,FOX
 
REM starting from n characters in and of m length;
1 PRINT MID$(S$,N,M)
 
REM starting from n characters in, up to the end of the string;
2 PRINT RIGHT$(S$,L-N+1)
 
REM whole string minus the last character;
3 PRINT LEFT$(S$,L-1)
 
REM starting from a known character within the string and of m length;
4 READ F$ :GOSUB 6
 
REM starting from a known substring within the string and of m length.
5 READ F$
 
6 FOR I = 1 TO L : IF MID$(S$,I,LEN(F$)) = F$ THEN PRINT MID$(S$,I,M) : RETURN
7 NEXT : RETURN</lang>
==={{header|BASIC256}}===
<lang BASIC256>c$ = "abcdefghijklmnopqrstuvwxyz"
413

edits