Created
August 7, 2018 06:44
-
-
Save nlitwin/1076a349666da70f5422a423b9675c77 to your computer and use it in GitHub Desktop.
Regex from Bash, VIM & Regex from Frontend Masters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# regular expressions | |
# system tools with regex: grep, sed, perl, vim, less | |
``` js | |
'1 two three \n'.replace(/1/, 'one') | |
``` | |
similar to: | |
``` sh | |
echo '1 two three' | sed 's/1/one/' | |
``` | |
# s/ means substitution | |
# sed -r and grep -E to not have to escape certain metacharacters | |
echo 'the the whatever dogs dogs etc' | sed 's/(\w+) \1/\1/g' | |
# prints the whatever dogs etc | |
# modify word in file | |
sed 's/cool/k001/g' -i file.txt | |
# perldoc perlreref docs for regex |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment