Substring/Top and tail: Difference between revisions

Content added Content deleted
(add sed)
(sed: add hint)
Line 2,174: Line 2,174:
Remove the last character:
Remove the last character:
<syntaxhighlight lang="sed">s/.$//</syntaxhighlight>
<syntaxhighlight lang="sed">s/.$//</syntaxhighlight>
Remove the first and the last character in one step:
Remove the first and the last character in one step (a bit more complex, to correctly handle single-character strings):
<syntaxhighlight lang="sed">s/.\(\(.*\).\)\{0,1\}/\2/</syntaxhighlight>
<syntaxhighlight lang="sed">s/.\(\(.*\).\)\{0,1\}/\2/</syntaxhighlight>