Artificial intelligent assistant

Remove punctuation except a particular symbol in a particular position I'm using `tr` to parse text and do several tasks like lower-case all words, remove punctuation and multiple spaces. The end result should be clean lower-case text with only alpha-numeric characters, except in a particular case: word$digit such as house$999 The formulation excepting this case is very simple. For example, just for the case where I remove punctuation, I would substitute it with a space using tr '[:punct:]' ' ' It's just a matter of using pipes to obtain the rest of the desired output. E.g., tr '[:upper:]' '[:lower:]' < $1 | tr '[:punct:]' ' ' | ... > $2 However, I'm having some trouble trying to figure out how to define the exception so that a `$` symbol between alphanumeric characters and a group of digits is maintained, while other instances, and all other punctuation symbols, are removed.

As per the answer from @xenoid, the following code works for me


echo -e "Hello.\
;132\$And; Another\$98?';:" | sed -e 's/\([[:alpha:]]\+\)\$\([[:digit:]]\+\)/\1 THIS \2/g' -e 's/[[:punct:]]//g' -e 's/ THIS /$/g' | tr '[:upper:]' '[:lower:]'


The result is:


hello
132and another$98

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 0d7fd44e684b292f761a8080e0f1894e