in reply to Variable in regex...
The right tool for this job is index, not a regex. Also, use code tags in your post, so your brackets don't get specially interpreted.