Well, sounds like homework to me, but looks like you have already put in the effort, and close to a solution, so I will reply (and chastise me if I shouldn't have, guys).
My solution does not use $1 (I need a little sed research myself), but instead uses \1 to back-reference the 1st parenthesized expression:
echo 'your input line' |
sed "s/the data is {\(.*\)}/the string was \(\"\1\"\)/"
and I did not have to escape the braces with backslashes.
$line =~ s/the data is {(.*)}/the string was \(\"$1\"\)/;
sorry for the confusion, since this is a model of the actual problem i faced. I could not give my company data directly here which would have been a solution for your doubt!
But sometimes it does not hear good to listen such comments when somebody tends to ask a question after a hectic session of trial in the office along with the tensions to finish the things within the last quarter of the year!!
My apologies, sskb. I am fairly new to this forum, and I will get better at spotting homework as opposed to someone trying to get their job done. I want to help (and learn in the process of helping), and follow the forum rules in the process.
I hope your year-end goes well, and Happy Holidays.