samedi 23 avril 2016

bash regex not working

So I have this code

function test(){
  local output="ASD[test]"
  if [[ "$output" =~ ASD\[(.*?)\] ]]; then
     echo "success";
  else
     echo "fail"
  fi;
}

And as you can see it's supposed to echo success since the string matches that regular expression. However this ends up returning fail. What did I do wrong?

Aucun commentaire:

Enregistrer un commentaire