This commit is contained in:
Maciej Caderek
2022-03-13 04:25:15 +01:00
parent db5d9f9243
commit 533051d4b5
7 changed files with 60 additions and 64 deletions

8
src/utils/isFEN.ts Normal file
View File

@@ -0,0 +1,8 @@
const REGEX =
/^([1-8kqrbnp]+\/)+[1-8kqrbnp]+ [wb] ([kq]+|-) ([a-h1-8]{2}|-) [01] \d+$/i;
const isFEN = (data: string) => {
return REGEX.test(data.trim());
};
export default isFEN;

8
src/utils/isPGN.ts Normal file
View File

@@ -0,0 +1,8 @@
const REGEX =
/((\[[a-z0-9]+ +"[^"\n\r]+"](\r\n|\r|\n))*(\r\n|\r|\n)+){0,1}\d+\. +[a-h1-8x+#=]+/i;
const isPGN = (data: string) => {
return REGEX.test(data);
};
export default isPGN;