SUB( ) Substitute Text
Format
SUB(string$,search$,replace$[,instance])[,ERR=stmtref])
Where:
instance | Optional. Integer. Which occurrence to find:
| |||||||
search$ | Value for which to search. String expression. Cannot be null. | |||||||
replace$ | Text to replace the original search text, if found. String expression. You must include a replace value; however, the value can be null; e.g. sub(A$,B$,"",0,err=100). | |||||||
stmtref | Program line number or statement label to which to transfer control. | |||||||
string$ | String expression containing the string in which to search-and-replace and perform the substitution. |
Returns
Converted string.
Description
The SUB( ) function performs a substitution within a string. The search value cannot be null. (That generates an Error #46: Length of string invalid.) If no substitutions occur, no error is generated.
Example
print 'CS';
list
A$="Hello there",B$="e",Z$=sub(A$,B$,"",0)
print Z$+" "+A$
end
->run
Hllo thr Hello there