What should do this code sample?
set l { A B C D }
lreplace $l 1 2 \[ \]
It returns {A {[} \] D}, however I want to have {A [ ] D}.
What am I doing wrong?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Your code does exactly what you want it to, you’re just reading the string rep of your output and misunderstanding it:
When you read the string rep, you’re seeing it escape the [ and ]. As you can see from the foreach output, the actual values are what you’re asking for. You can use
jointo get the string you’re interested in if what you want is just a string with the characters in question.