Convert text to upper case
This is downright trivial.
upper.bat
Code: Select all
@repl ".+" "$0.toUpperCase()" j
Sample usage:
Code: Select all
C:\>echo HELLO world!|upper
HELLO WORLD!
Convert text to lower case
Another trivial example
lower.bat
Code: Select all
@repl ".+" "$0.toLowerCase()" j
Sample usage:
Code: Select all
C:\>echo HELLO world!|lower
hello world!
Convert text to mixed case (initial caps)
This is a bit more interesting.
initCaps.bat
Code: Select all
@repl "(\b.)|.*?\b" "$1?$0.toUpperCase():$0.toLowerCase()" j
Sample usage:
Code: Select all
C:\>echo HELLO world!|initCaps
Hello World!
ROT13 cipher
It is simple to implement the classic symmetric rotation cipher that can be used to both encode and decode a message.
ROT13.BAT
Code: Select all
@repl "[a-z]" "var c=$0.charCodeAt(0), off=c>=97?97:65; String.fromCharCode((c-off+13)%%26+off)" ij
Sample usage:
Code: Select all
C:\>echo Hello world!|rot13
Uryyb jbeyq!
C:\>echo Uryyb jbeyq!|rot13|rot13
Hello world!
English to Pig Latin translator
Now this is fun

This fairly sophisticated implementation has the following features:
- If word has initial capitalization, then so does translation, else each letter's case is preserved
- Properly handles contractions
- Treats hyphenated words as two words
- Properly handles Y, even in a word like Yttrium (a rare earth metal)
- Properly handles Qu
- Does not translate "words" containing any numeric digits
PigLatin.bat
Code: Select all
@repl "\b(?:((?:y(?=[aeiou])|qu|[bcdfghjklmnpqrstvwxz])(?:qu|[bcdfghjklmnpqrstvwxz])*)+([a-z']*)|([a-z']+))(?![a-z\d])" ^
"var out=$3?$3+'way':$2+$1+'ay';^
$0.substr(0,1).toUpperCase()+$0.substr(1).toLowerCase()==$0?out.substr(0,1).toUpperCase()+out.substr(1).toLowerCase():out" ij
Sample Usage:
Code: Select all
C:\>echo Hello world!|pigLatin
Ellohay orldway!
Dave Benham