Regex to match something based on what was matched before

前端 未结 1 1025
天涯浪人
天涯浪人 2021-01-19 18:44

I\'m trying to write a regular expression to validate moves in algebraic chess notation. Here\'s what I have so far:

/
    O-O(-O)?                 # Castlin         


        
相关标签:
1条回答
  • 2021-01-19 19:21

    Matching the adjacent letter is not hard using alternations, but you won't find anything compact as there is no character arithmetic in regex.

    Someone just posted a similar question out of sympathy for your plight.

    The long way is the only way.

    0 讨论(0)
提交回复
热议问题