2

replacing all matches in a line

view story
linux-howto

http://www.linuxquestions.org – I have .pgn file (chess) that I'd like to reformat. I want to separate the line into one move per line from 1. e4 e6 2. d4 Qh4 3. Nc3 Bb4 etc to 1. e4 e6 2. d4 Qh4 3. Nc3 Bb4 etc [\n\s]?[\d]+[.]\s\+ pretty much matches the pattern of the move numbers and kregeditor highlights all the move numbers (and the spaces around them) I've tried sed s/[\n\s]?[\d]+[.]\s\+/\n&/ and only the first occurrence in a line is replaced/substituted. since \n is non-printable, my actual test was sed s/[\n\s]?[\d]+[.]\s\+/XXX\n&/ obtaining XXX 1. e4 e6 2. d4 Qh4 3. Nc3 Bb4 etc how should I process all the moves in a line? ~steve~ (HowTos)