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'
精彩评论