Regular Expressions 101

Community Patterns

Community Library Entry

0

Regular Expression
ECMAScript (JavaScript)

/
[0-9]{1,2}\. [\w+()=#-]+ [\w+()=#-]+|[0-9]{1,2}\. [\w+()=#-]+
/
g

Description

In my use case, I had to parse PGN this way for my book opening apps.

Transformed result later

{ 
 1:  {
   black: 'c6'
   white: 'e4'
   fen: ...
  }
}

Thanks to @metalsadmin for the leads

Submitted by Muhammad Surga Savero - 4 years ago