Regular Expressions 101

Community Patterns

Your search did not match anything

Community Library Entry

1

Regular Expression
Python

r"
^(?:(?:(?P<piece>[prnbkq])?\s*(?P<from_col>[a-h])?(?P<from_row>[1-8])?\s*(?P<capture>x)?\s*(?P<to>[a-h][1-8]))|(?P<k_castling>(?P<char>[0O])\s*-\s*(?P=char))|(?P<q_castling>(?P<char2>[0O])\s*-\s*(?P=char2)\s*-\s*(?P=char2)))$
"
igm

Description

Detects chess Algebraic notation. See: https://en.wikipedia.org/wiki/Algebraic_notation_(chess)

Using Regexp groups to know what information is present on the notation (pieces or move disambiguation).

Only supported by Flavor that has named group verification.

Submitted by Johan JANIN - 9 days ago