I would like to replace a character with another character in a string but only when the character occurs within a delimited substring of the string. For example, for the string:
b[b]abc[abc]bbb[bbb]
I would like to change "b" to "x" but only if it is within square brackets "[...]". Thus, the desired result is the string:
b[x]abc[axc]bbb[xxx]
My preference would be a sed or bash solution because they are in my comfort zone, but any solution that would work for Mac OS X would be fine. From searching, it seems that this can be accomplished with sed using negative lookahead and negative lookbehind, but I don't believe those features are available on the Mac version of sed.