ReplaceParser
The replace tag replaces specific characters or substrings in a string with new values.
The parameter should be split by a comma (,
), containing the characters/text to find before the comma and the replacement text after.
Usage
import { Interpreter, ReplaceParser } from 'tagscript';
const ts = new Interpreter(new ReplaceParser());
const { Interpreter, ReplaceParser } = require('tagscript');
const ts = new Interpreter(new ReplaceParser());
API
Check ReplaceParser for the API documentation.
For End Users
Syntax
{replace(find,replacement):text}
Examples
{replace(o,i):welcome to the server}
# welcime ti the server
{replace(1,6):1637812}
# 6637862
{replace(, ):Test}
# T e s t
{replace(old,new):This is the old way of doing things}
# This is the new way of doing things
{replace(@,at):user@example.com}
# useratexample.com
Notes
- All occurrences of the search text will be replaced
- The replacement is case-sensitive
- If you need to include a comma in the search or replacement text, it should be the last comma in the parameter
- Empty strings are valid for both search and replacement values
Last updated on