Cuis-Automatically escape a complex string: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 11: | Line 11: | ||
* Go back to the Workspace and type this |
* Go back to the Workspace and type this |
||
<syntaxhighlight lang="smalltalk"> |
<syntaxhighlight lang="smalltalk"> |
||
te model actualContents asString . => 'echo "hello, i''m nicola, who are you?"' |
te model actualContents asString . "=>" 'echo "hello, i''m nicola, who are you?"' |
||
</syntaxhighlight> |
</syntaxhighlight> |
||
* Voila<nowiki>', you have your string automatically escaped, notice the doulbe $' character in i''</nowiki>m nicola. |
* Voila<nowiki>', you have your string automatically escaped, notice the doulbe $' character in i''</nowiki>m nicola. |
Latest revision as of 22:34, 4 May 2025
Problem You have a long shell command, or an SQL command, or something else which may contain tne $'
Character. You can escape the $'
by doubling it yourself but it will become quite hard to read your original string. Is there a better way?
Solution. Yes, there is a nice trick to achieve that.
- Suppose the string you want to quote is
echo "i'm nicola, who are you?"
- Open a TextMorph
te := TextEditor openTextEditor .
- Write the string into it
- Go back to the Workspace and type this
te model actualContents asString . "=>" 'echo "hello, i''m nicola, who are you?"'
- Voila', you have your string automatically escaped, notice the doulbe $' character in i''m nicola.
- Some time ago I made a video tutorial about this with a much worst string. There the procedure is a bit different, it was specific for Squeak.
Dr. Nicola Mingotti firt wrote this on 21-Sep-2021. Tested in Cuis5.0-4834.image