开发者

sed pattern for "1.2", "1.2.3", "1.2.3.4", "1.2.3.4.5", …

开发者 https://www.devze.com 2023-02-01 05:42 出处:网络
I am trying to use sed for matching this pattern: it has multiple parts, each part is separated by a full stop, and the content is a non-empty sequence of digits, like:

I am trying to use sed for matching this pattern: it has multiple parts, each part is separated by a full stop, and the content is a non-empty sequence of digits, like:

"1", "1.2", "192.168.0.1", …

Does sed support grouping a sequence of regex a开发者_运维问答s a group and use + or *, etc. on it?

I'm grateful for any help. Thank you!


Since you are matching patten you can use grep as:

grep -Eo '[0-9]+(\.[0-9]+)*'

In sed you can do:

sed  -r 's/[0-9]+(\.[0-9]+)*/replacement/'    

See it

0

精彩评论

暂无评论...
验证码 换一张
取 消