Last Updated: February 25, 2016
·
370
· knuthaug

Matching regexps directly in bash

It may be old news to everyone, but again, it may not.

#!/bin/bash

regxp="[a-z]+[0-9]*"

if [[ $string =~ $regexp ]]
then
    #do stuff
fi