Regular Expressions 101

chess move detector

Open Workspace
  • JavaScript
  • Match
1

Regular Expression

/
^((?:[NBRQK]([a-h1-8])?x?(?!\2)[a-h](?!\2)[1-8]|[NBRQK]x?[a-h][1-8]|(?:[a-h]x)?[a-h](?:[1-8](?:\(ep\))?|[18]=[NBRQ])|(?:0-){1,2}0)\+{0,2})$
/

Description

Detects SYNTACTICALLY correct chess moves (i.e. it doesn't check whether the move itself is actually valid)

Submitted by Terence Linnell