Skip to content

Instantly share code, notes, and snippets.

@marji
Created October 31, 2013 13:33
Show Gist options
  • Save marji/7249796 to your computer and use it in GitHub Desktop.
Save marji/7249796 to your computer and use it in GitHub Desktop.
Bash has regular expression built in. Temporary file, please ignore.
#!/bin/bash -x
string="matchthis, but not this"
pattern="([a-z]+)"
[[ $string =~ $pattern ]]
result=${BASH_REMATCH[1]}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment