GLBasic User Manual

Main sections

REPLACE$()

new$ = REPLACE$(where$, find$, repl$)



Replaces the text find$ within the string where$ with the text repl$. It will replace multiple occurrences at once.
If the string find$ is not found than the original string where$ will be returned.

// Replace

PRINT "Turn a Frog into a Prince", 0, 0

a$ = "Frog"
PRINT a$, 0, 20

a$ = REPLACE$(a$, "F", "P")
PRINT a$, 0, 40

a$ = REPLACE$(a$, "og", "ince")
PRINT a$, 0, 60

SHOWSCREEN
MOUSEWAIT


Output:
Turn a Frog into a Prince
Frog
Prog
Prince

See also...