开发者

sed question insert colons

Hello I want to use sed to 开发者_如何学Gosearch a file for 3-5 alpha chars followed by 3 numbers and insert a colon after the first alpha char and a colon before the numbers


Using GNU sed on Ubuntu 10.04.2 LTS:

sed -r -e 's/([a-zA-Z]{3,5})([0-9]{3})/\1:\2/g'

EDIT: Misread the OP's question. Better answer:

sed -r -e 's/([a-zA-Z])([a-zA-Z]{2,4})([0-9]{3})/\1:\2:\3/g'
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜