I have this regex:
It would be used by me for Chess FEN strings.
I wonder if regex
[A-Za-z] is faster than
[RNBQKrnbqk]? I only need to check the given letters (but no other letters will appear).
My thoughts are:
[A-Za-z]- the regex engine can match if a char is
65 <= c <= 90or
97 <= c <= 122. Worst case is 4 comparisons.
[RNBQKrnbqk]- the engine checks if the inspected char equals every given character in the group. Worst case is 10 comparisons.
Am I understanding regex correctly?