lib/pgn2fen.rb
##
# clean pgn - remove comments and other unrequired text
clean pgn - remove comments and other unrequired text
clean pgn - remove comments and other unrequired text
def clean_pgn(pgn)
      pgn.strip!
      pgn.sub!("1-0", ""); pgn.sub!("0-1", ""); pgn.sub!("1/2-1/2", "")
      pgn.gsub!("#", ""); pgn.gsub!("*", "")
      pgn.gsub!(/\$(\w+)/, "")
      pgn = clean_comments(pgn)
      pgn = clean_subvariations(pgn)
    end
def clean_pgn ( pgn ) pgn . strip! pgn . sub! ( "1-0" , "" ) ; pgn . sub! ( "0-1" , "" ) ; pgn . sub! ( "1/2-1/2" , "" ) pgn . gsub! ( "#" , "" ) ; pgn . gsub! ( "*" , "" ) pgn . gsub! ( / \$ ( \w +) / , "" ) pgn = clean_comments ( pgn ) pgn = clean_subvariations ( pgn ) end
clean pgn - remove comments and other unrequired text
clean pgn - remove comments and other unrequired text
# clean result # clean mate and incomplete game marker #remove all chessbase $ characters #remove all comments - content within {} #pgn.gsub!(/(\{[^}]+\})+?/, "") #remove all subvariations - content within () #pgn.gsub!(/(\([^}]+\))+?/, "")
pgn
<not_specific>