assigning variables in sed command

I need to assign a variable within a variable in a sed command.
I tried doing the following in c shell.

set left = 1
set right = 2
set segment = qwerty

sed -n -e "/$segment{$left}/,/$segment{$right}/p" file.txt

what is wrong with this syntax?

Is the -e really needed? -e is for executing a script.

sed goes by
sed 's/<searchtext>/<replacementtext>/' file

using variables within sed

a=abcdef
b=def
echo abcdefghij | sed "s/$b/$a/"
abcabcdefghij

hope this helps.

did you mean :

sed -ne "/$segment${left}/,/$segment${right}/p" file.txt

?