string strRegex = @"ISBN\x20(?=.{13}$)\d{1,5}([- ])\d{1,7}\1\d{1,6}\1(\d|X)$"; RegexOptions myRegexOptions = RegexOptions.None; Regex myRegex = new Regex(strRegex, myRegexOptions); string strTargetString = @"Thank you for picking up WPF 4 Unleashed! Windows Presentation Foundation (WPF) is Microsoft’s premier technology for creating Windows graphical user interfaces, whether they consist of plain forms, document-centric windows, animated cartoons, videos, immersive 3D environments, or all of the above. WPF is a technology that makes it easier than ever to create a broad range of applications. " + "\n" + @"ISBN-13: 978-0-672-33119-0 " + "\n" + @"ISBN-10: 0-672-33119-5" + "\n" + @"It’s also the basis for Silverlight, which has extended WPF technology onto the Web and into devices such as Windows phones."; foreach (Match myMatch in myRegex.Matches(strTargetString)) { if (myMatch.Success) { Console.WriteLine(myMatch.Groups[1].Value); } }
ISBN(-1(?:(0)|3))?:?\x20+(?(1)(?(2)(?:(?=.{13}$)\d{1,5}([ -])\d{1,7}\3\d{1,6}\3(?:\d|x)$)|(?:(?=.{17}$)97(?:8|9)([ -])\d{1,5}\4\d{1,7}\4\d{1,6}\4\d$))|(?(.{13}$)(?:\d{1,5}([ -])\d{1,7}\5\d{1,6}\5(?:\d|x)$)|(?:(?=.{17}$)97(?:8|9)([ -])\d{1,5}\6\d{1,7}\6\d{1,6}\6\d$)))
ISBN-13: 978-1-4028-9462-6
ISBN: 1284233-2-1-1
ISBN(-1(?:(0)|3))?:?\x20(\s)*[0-9]+[- ][0-9]+[- ][0-9]+[- ][0-9]*[- ]*[xX0-9]
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)