ISBN Number regular expression

string pattern = @"ISBN\x20(?=.{13}$)\d{1,5}([- ])\d{1,7}\1\d{1,6}\1(\d|X)$";


// Valid
Console.WriteLine(Regex.IsMatch(@"ISBN 0 93028 923 4"@"ISBN\x20(?=.{13}$)\d{1,5}([- ])\d{1,7}\1\d{1,6}\1(\d|X)$"));

// Valid
Console.WriteLine(Regex.IsMatch(@"ISBN 1-56389-668-0"@"ISBN\x20(?=.{13}$)\d{1,5}([- ])\d{1,7}\1\d{1,6}\1(\d|X)$"));

// Invalid
Console.WriteLine(Regex.IsMatch(@"ISBN 123 456-789X"@"ISBN\x20(?=.{13}$)\d{1,5}([- ])\d{1,7}\1\d{1,6}\1(\d|X)$"));
Author Paul Hayman

Paul is the COO of kwiboo ltd and has more than 20 years IT consultancy experience. He has consulted for a number of blue chip companies and has been exposed to the folowing sectors: Utilities, Telecommunications, Insurance, Media, Investment Banking, Leisure, Legal, CRM, Pharmaceuticals, Interactive Gaming, Mobile Communications, Online Services.

Paul is the COO and co-founder of kwiboo ( and is also the creator of GeekZilla.


ethemsulan said:

Hi, ISBN format is 978-9944-300-19-3 Can you help me for regular expression? Thanks

28/Apr/2010 22:15 PM

levdeo said:

Yea!!!,great article

06/Oct/2012 08:30 AM

Add Comment


Your comment has been received and will be shown once it passes moderation.