ISBN 10:
it has 4 groups separated with ' ' or '-'
group need to has 1-5 digits
group need to has max 7
max 6
1 digit or letter 'X'
ISBN 13
5 groups separated with ' ' or '-'
group - always has 3 digits
group same as 1st in isbn10
group same as 2nd in isbn10
group same as 3rd in isbn10
group same as 4th in isbn10
i need to construct regexp which can match ISBN10 OR ISBN13
i tried something like this:
[0-9]{0,3}[- ]{0,1}[0-9]{1,5}[- ]{1}[0-9]{0,7}[- ]{1}[0-9]{0,6}[- ]{1}[0-9X]{1}
but it works only on regextester.com not in my grep -o command
can you help?
also, can you tell me, in what reason doesnt my regex work?
The reason is that the mentioned Regex tester supports PCREs (Perl Compatible Regular Expressions) while regular grep does not. You might have some success using 'grep -E' or egrep if available.