Created
April 18, 2019 16:19
-
-
Save timhodson/3976550490de273c431697b8a0b3c260 to your computer and use it in GitHub Desktop.
Quote meta characters in a string to be used in a regex.
This file contains hidden or 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
#!/bin/bash | |
# quote meta characters | |
python -c "import sys,re; [sys.stdout.write(re.escape(line)) for line in sys.stdin]" < <(echo -n "$1") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment