Remove (not just unset) multiple strings from an array without knowing their positions
<p>Say I have arrays </p>

<pre><code>a1=(cats,cats.in,catses,dogs,dogs.in,dogses)
a2=(cats.in,dogs.in)
</code></pre>

<p>I want to remove everything from a1 that matches the strings in a2 after removing ".in" , in addition to the ones that match completely(including ".in"). </p>

<p>So from a1, I want to remove cats, cats.in, dogs, dogs.in, but not catses or dogses.</p>

<p>I think I'll have to do this in 2 steps. I found how to cut the ".in" away:</p>

<pre><code>for elem in "${a2[@]}" ; do 
    var="${elem}"
    len="${#var}"
    pref=${var:0:len-3}
done
</code></pre>

<p>^ this gives me "cats" and "dogs"</p>

<p>What command do I need to add to the loop <strong>remove</strong> each elem from a1? </p>