From: Dr. David Kirkby on 13 Apr 2010 18:47 On Apr 13, 9:06 am, pk <p...(a)pk.invalid> wrote: > Dr. David Kirkby wrote: > > On Apr 13, 7:58 am, pac...(a)kosh.dhis.org (Alan Curry) wrote: > >> In article > >> <b233480b-a7d5-4ba8-a3e2-8147d6b38...(a)u34g2000yqu.googlegroups.com>, Dr. > >> David Kirkby <david.kir...(a)onetel.net> wrote: > >> | > >> |The games start with: > >> | > >> |[Event " > >> | > >> |and end when the next > >> | > >> |[Event " starts. In other words, I can't assume a game ends on a new > >> |line, or there are are blank lines between games. > > >> Are you sure? In PGN export format, each tag is required to be on a line > >> by itself and blank lines between games are required. In PGN import > >> format, you can't even count on the Event tag existing. > > > I''ll rephrase that. I can't rely on a record ending when there is a > > blank line, as there are often blank lines between the tags and the > > moves - in fact, looking at the standard, such a blank line is > > required in export format. > > So to be clear, do you need to exclusively rely upon seeing "[Event" to > identify the start of a game, or can you just assume that a game is composed > of two "paragraphs", where paragraphs are separated by runs of empty lines? I need to exclusively rely on seeing "[Event" to identify the start of a game. But the information posted by Bill Marcum, that . matches any character and * any number of the proceeding character solved my problem. Dave Dave
From: Dr. David Kirkby on 13 Apr 2010 18:47
On Apr 13, 9:42 pm, Bill Marcum <marcumb...(a)bellsouth.net> wrote: > On 2010-04-13, Dr. David Kirkby <david.kir...(a)onetel.net> wrote:> The following for example will output all the games which start > > > [Event "ICC 45 > > > $ gawk '/^\[Event "/ { inhibit = ($0 ~ /^\[Event "ICC 45/) } > > inhibit { print }' < icc.pgn > > > but I don't know how to adapt the bit around "ICC 45" to be "ICC > ><something> (standard)"] > > > I thought a '*' could be used to match the <something> but that does > > not appear to work. If anyone has any ideas, Here are a few more > > games, which could be used for test purposes. > > Use '.*' to match any string in regular expressions. '.' matches any single > character and '*' matches any number of the previous item. Thank you Bill, that solved it. |