Have a look at quotemeta.
In reply to Re: Regular Expressions with varialbe with "[]" by hdb in thread Regular Expressions with varialbe with "[]" by herman4016