[LIB-9] Add reserved, NAG and semicolon comment PGN tokens
[chesshog.git] / chesshog-format / src / main / java / org / hedgecode / chess / pgn / PGNUtils.java
index 884a388..ae5c046 100644 (file)
@@ -32,6 +32,7 @@ public final class PGNUtils {
     private static final String SHIELD_REGEX = "\\\\";
 
     private static final String EMPTY = "";
+    private static final String TAB = "\t";
     private static final String CRLF_REGEX = "\\r?\\n";
 
     public static String match(String source, String regex) {
@@ -82,6 +83,10 @@ public final class PGNUtils {
         return pgn.replaceAll(CRLF_REGEX, PGN_SPACE);
     }
 
+    public static String tabCrlf(String pgn) {
+        return pgn.replaceAll(TAB, PGN_SPACE).replaceAll(CRLF_REGEX, TAB);
+    }
+
     private PGNUtils() {
         throw new AssertionError(
                 String.format("No %s instances!", getClass().getName())