The remove and replace commands are very similar so we will be learning about both commands in this part.
Remove
The remove command removes specific text from the input.
There are four ways you can remove text using this command: by specifying the literal text or regular expression you wish to remove, by removing individual characters, by removing all text at once, or by specifying a span of characters between two points to remove.
We will look at the first method now.
Hello world!>> remove every "l"Heo word!
This will remove every “l” from the input.
The remove command also supports text modifiers and multiple instances.
remove every regex "[^a-z]+"remove every xcase "l"remove first "l"remove inst 1, 3, 5 "l"
Removing characters
You can remove characters from the input using character indexes with the remove command.
Hello world!>> remove char 1ello world!
Hello world!>> remove char 1, 7, lastello orld
Everything keyword
The everything keyword will match with all text in the input. The everything keyword can be replaced with a *.
Hello world!>> remove everything 
Hello world!>> remove * 
As you can see, everything in the input was removed. You will likely not find much use for this command on its own, however it can be very useful with additional logic (we will cover this later).
Spans
Spans are used to match with all the text between two points. You can specify the start and end points of a span using text positions, a character indexes, or a combination of the two.
Hello world!>> remove everything from pos 0 to pos 6world!
As you can see, all text between position 0 and position 6 has been removed. As stated above, you can also specify spans with character indexes.
Hello world!>> remove everything from char 1 to char 6world!
Hello world!>> remove everything from pos 0 to char 6world!
All of these commands produce the same output.
Shorthand
Writing out a span can become quite tedious. Luckily there are many shorter ways to specify a span.
everything from pos 0 to pos 2everything from [0] to [2]* from [0] to [2][0-2]
everything from char 1 to char 3everything from (1) to (3)* from (1) to (3)(1-3)
everything from pos 0 to char 3everything from [0] to (3)* from [0] to (3)[0-3)
everything from char 1 to pos 2everything from (1) to [2]* from (1) to [2](1-2]
All of these are valid and each block of four commands produce the same result.
Let’s rewrite the first command and make it much shorter:
Hello world!>> remove [0-6]world!
Documentation
More information on the remove command can be found on the documentation page.
Replace
The replace command is very similar to the remove command, only instead of removing the selected text, you specify which text to replace the selection with.
Hello world!>> replace every "o" with "bar"Hellbar wbarrld!
You can use all the same keywords with the replace command as you can with the remove command.
replace every regex "foo" with "bar"replace every xcase "foo" with "bar"replace char 1, 3, 5 with "bar"replace everything with "bar"replace [0-6] with "bar"
Documentation
More information on the replace command can be found on the documentation page.
Test your knowledge
Next up, there will be a short quiz to make sure you understand everything you have learnt in part 2.2. If you do not wish to take this test, click skip quiz.
