fork(4) download
  1. #!/bin/bash
  2. a='mary jane uger dodo baba'
  3. b='mary'
  4. c='ma'
  5.  
  6. # will match
  7. [[ "$a" =~ "$b"( |$) ]] && echo "a matches b" || echo "a doesn't match b"
  8.  
  9. # won't match
  10. [[ "$a" =~ "$c"( |$) ]] && echo "a matches c" || echo "a doesn't match c"
  11.  
Success #stdin #stdout 0.02s 5312KB
stdin
Standard input is empty
stdout
a matches b
a doesn't match c