isbn10MaybeRegStr top-level property
Regular expression string pattern for validating ISBN-10 format.
This pattern validates if a string matches the basic ISBN-10 format:
- Exactly 10 characters
- Either 10 digits (0-9), or 9 digits followed by 'X'
This pattern validates only the format, not the mathematical validity of the ISBN-10 (checksum verification).
The pattern does not accept hyphens or spaces commonly used in ISBN display format (e.g., "0-306-40615-2").
Example:
String testISBN1 = "0306406152"; // 10 digits
String testISBN2 = "123456789X"; // 9 digits + X
String testISBN3 = "0-306-40615-2"; // Contains hyphens (will fail)
bool isValid1 = isbn10MaybeReg.hasMatch(testISBN1); // true
bool isValid2 = isbn10MaybeReg.hasMatch(testISBN2); // true
bool isValid3 = isbn10MaybeReg.hasMatch(testISBN3); // false
Implementation
String isbn10MaybeRegStr = r'^(?:[0-9]{9}X|[0-9]{10})$';