Reasons for not using `\s` and `\S`

大城市里の小女人 提交于 2021-02-08 11:01:40

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!