#!/bin/bash

s="foo FOOfOoFoOBARBARbarbarbAr";
grep -Eo '[Ff][Oo][Oo]|BAR' <<< "$s"

grep -Po '(?i:foo)|BAR' <<< "$s"
