Hello everyone.
This question is regarding ISBN number checking. I've done it with my own algorithm, which is pretty bad in consideration about the total lines of code.
Now I want to improve it, I guess the best practice wold be using regular expression to handle this string validation:
Say, I've got the user input string with fgets(array, 20, stdin);
If it is a valid ISBN number, then it must have a valid format:
- the valid char set is:"0123456789 X- \n"
- there must be exactly 10 "digit" chars, which are in this set "0123456789 X"
- char 'X' must either not exist or at the last position of the digits.
...
It's about the content checking, I don't know how to apply the logic into the code.
Thanks in advance!
Sincerely yours,
Matt
This question is regarding ISBN number checking. I've done it with my own algorithm, which is pretty bad in consideration about the total lines of code.
Now I want to improve it, I guess the best practice wold be using regular expression to handle this string validation:
Say, I've got the user input string with fgets(array, 20, stdin);
If it is a valid ISBN number, then it must have a valid format:
- the valid char set is:"0123456789 X- \n"
- there must be exactly 10 "digit" chars, which are in this set "0123456789 X"
- char 'X' must either not exist or at the last position of the digits.
...
It's about the content checking, I don't know how to apply the logic into the code.
Thanks in advance!
Sincerely yours,
Matt
Comment