Using different delimiters in sed (2010)
backreference.org
Using different delimiters in sed (2010)
1–10 of 30 posts
Re: Using different delimiters in sed (2010)
#2Re: Using different delimiters in sed (2010)
#3Re: Using different delimiters in sed (2010)
#4With a bit of exposure, commands like
s/foo/bar/
and
s,foo,bar,
can be read with equal ease.
Re: Using different delimiters in sed (2010)
#5The common alternate character, for those cases where normal slashes are not suitable, is a comma character; ‘,’. With Sed code, readability is always an issue, and it can be improved by not using just any character and limiting yourself to as few alternative modes of syntax as possible. With a bit of exposure, commands like s/foo/bar/ and s,foo,bar, can be read with equal ease.
I've always used "|" since it's so visually similar, and you always want to quote regular expressions anyway.
Re: Using different delimiters in sed (2010)
#6The common alternate character, for those cases where normal slashes are not suitable, is a comma character; ‘,’. With Sed code, readability is always an issue, and it can be improved by not using just any character and limiting yourself to as few alternative modes of syntax as possible. With a bit of exposure, commands like s/foo/bar/ and s,foo,bar, can be read with equal ease.
> The common alternate character, for those cases where normal slashes are not suitable, is a comma character; ‘,’. I've always used "|" since it's so visually similar, and you always want to quote regular expressions anyway.
Re: Using different delimiters in sed (2010)
#7The common alternate character, for those cases where normal slashes are not suitable, is a comma character; ‘,’. With Sed code, readability is always an issue, and it can be improved by not using just any character and limiting yourself to as few alternative modes of syntax as possible. With a bit of exposure, commands like s/foo/bar/ and s,foo,bar, can be read with equal ease.
> The common alternate character, for those cases where normal slashes are not suitable, is a comma character; ‘,’. I've always used "|" since it's so visually similar, and you always want to quote regular expressions anyway.
Re: Using different delimiters in sed (2010)
#8The common alternate character, for those cases where normal slashes are not suitable, is a comma character; ‘,’. With Sed code, readability is always an issue, and it can be improved by not using just any character and limiting yourself to as few alternative modes of syntax as possible. With a bit of exposure, commands like s/foo/bar/ and s,foo,bar, can be read with equal ease.
@
because it is so weird and unexpected people are unlikely to misread the command and think it does something with multiple commandstho perl’s qr (quote regex) operator is miles ahead, it even supports natural pairs of opening/closing delimiters
Re: Using different delimiters in sed (2010)
#9The common alternate character, for those cases where normal slashes are not suitable, is a comma character; ‘,’. With Sed code, readability is always an issue, and it can be improved by not using just any character and limiting yourself to as few alternative modes of syntax as possible. With a bit of exposure, commands like s/foo/bar/ and s,foo,bar, can be read with equal ease.
Re: Using different delimiters in sed (2010)
#10The common alternate character, for those cases where normal slashes are not suitable, is a comma character; ‘,’. With Sed code, readability is always an issue, and it can be improved by not using just any character and limiting yourself to as few alternative modes of syntax as possible. With a bit of exposure, commands like s/foo/bar/ and s,foo,bar, can be read with equal ease.
I prefer @ because it is so weird and unexpected people are unlikely to misread the command and think it does something with multiple commands tho perl’s qr (quote regex) operator is miles ahead, it even supports natural pairs of opening/closing delimiters
s{/u/r/i}{do something}
Sadly doesn’t support that (or at least none of the sed’s I’ve used). So I fallback to using hash (#) instead (for no particular reason aside that’s what I’ve always used).