fork download
  1. #!/bin/bash
  2. rx='(?:\G(?!^),\s*|\bG\()\K[^(),]+(?=[^()]*\))'
  3. example="not me G(select me, and me) G(select me) G(also me)"
  4. grep -oP "$rx" <<< "$example"
Success #stdin #stdout 0s 4292KB
stdin
Standard input is empty
stdout
select me
and me
select me
also me