I am working on a hobby chess project with HTML / CSS / PHP. I was not familiar with chess before, so I decided to create an instrument that would show which moves were allowed based on the type and square of the given part.
I have an HTML form with two text fields: one for the fragment type, and the other for the current square of the specified part. Everything works, but I want to enable validation using regular expressions.
Valid, case-insensitive input for the part type: p, pawn, r, rook, b, bishop, n, knight, q, queen, k, king.
Valid, case-insensitive inputs for a square are LetterNumber, where Letter can be AH and the number can be 1-8.
So, I am wondering if regular expressions / practicals are possible, and if so, can someone tell me what it is? I think I should just use a conditional statement with logical elements for the type of pieces, but I'm curious to see if there are other solutions.
source
share