fork download
  1. #!/bin/bash
  2. s="say: a[aa] and a[aa]! to bbb, not ba[aa] or a[aa]b"
  3. sed -E 's~([^_[:alnum:]]|^)a\[aa]([^_[:alnum:]]|$)~\1bbb\2~g' <<< "$s"
Success #stdin #stdout 0s 4468KB
stdin
Standard input is empty
stdout
say: bbb and bbb! to bbb, not ba[aa] or a[aa]b