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
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.