问题
In GNU sed answers using the regular expression extensions \s
which matches whitespace caracters and its dual \S
which matches non-whitespace characters, seem to be shied from. Why is this?
回答1:
They're GNU-only and so non-portable to other seds, that's all. Just wrt matching white space and use of -E
(idk about the rest), the example you referenced would work with OSX/BSD sed or GNU sed as written, but if you used \s
instead of [ \t]
then it'd stop working in OSX/BSD sed. Personally I'd have used [[:space:]]
for robustness and portability.
来源:https://stackoverflow.com/questions/54887368/reasons-for-not-using-s-and-s