Skip to content

Instantly share code, notes, and snippets.

@timhodson
Created April 18, 2019 16:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timhodson/3976550490de273c431697b8a0b3c260 to your computer and use it in GitHub Desktop.
Save timhodson/3976550490de273c431697b8a0b3c260 to your computer and use it in GitHub Desktop.
Quote meta characters in a string to be used in a regex.
#!/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