Try:
Code:
echo 'text[2*?!]'|sed 's/\(text\)\(\[[2-4]\)/vinay\2/'
\(text\) searces for an exact match for
text
\(\[[2-4]\) searches for a litteral
[ character followed by a number between
2 and
4
Therefore
\1 refers to
text (but we are not using this part.
\2 refers (in this instance) to
[2
We replace the search with vinay followed by the second reference [2 the rest of the string is kept as it wasn't part of the search.
HTH,
Dis