出版时间:2013-1 出版社:东南大学出版社 作者:菲茨杰拉德
Tag标签:无
内容概要
《正则表达式入门(影印版)(英文版)》主要讲述了,如果你是正则表达式新手,那么这本容易上手的指南就是很好的入门读物。你将在大量实例的帮助下循序渐进地学习相关基础内容,学习通过匹配特定关键字、字符和模式以实现匹配、抽取和转换文本的第一手知识。
正则表达式是程序员的重要工具,在很多Unix工具和Perl、Java、JavaScript、C#等编程语言中会用到。学完《正则表达式入门(影印版)(英文版)》后,你将熟练掌握正则表达式中最常用的语法,还将领悟灵活运用它们以省时省力的相关技巧。
作者简介
作者:(美国)菲茨杰拉德(Michael Fitzgerald) Michael Fitzgerald,程序员兼技术顾问,为O'Reilly和JohnWiley&Sons出版社编写过多部技术书籍,还为O'ReillyNetwork撰写过多篇文章。他是XML RELAX NG schema语言的创始成员之一。
书籍目录
Preface 1. What Is a Regular Expression? Getting Started with Regexpal Matching a North American Phone Number Matching Digits with a Character Class Using a Character Shorthand Matching Any Character Capturing Groups and Back References Using Quantifiers Quoting Literals A Sample of Applications What You Learned in Chapter 1 Technical Notes 2. Simple Pattern Matching Matching String Literals Matching Digits Matching Non-Digits Matching Word and Non-Word Characters Matching Whitespace Matching Any Character, Once Again Marking Up the Text Using sed to Mark Up Text Using Perl to Mark Up Text What You Learned in Chapter 2 Technical Notes 3. Boundaries The Beginning and End of a Line Word and Non-word Boundaries Other Anchors Quoting a Group of Characters as Literals Adding Tags Adding Tags with sed Adding Tags with Perl What You Learned in Chapter 3 Technical Notes 4. Alternation, Groups, and Backreferences Alternation Subpatterns Capturing Groups and Backreferences Named Groups Non-Capturing Groups Atomic Groups What You Learned in Chapter 4 Technical Notes 5. (haraaer (lasses Negated Character Classes Union and Difference POSIX Character Classes What You Learned in Chapter 5 Technical Notes 6. Matching Unicode and Other Characters Matching a Unicode Character Using vim Matching Characters with Octal Numbers Matching Unicode Character Properties Matching Control Characters What You Learned in Chapter 6 Technical Notes 7. Quantifiers Greedy, Lazy, and Possessive Matching with *, +, and ? Matching a Specific Number of Times Lazy Quantifiers Possessive Quantifiers What You Learned in Chapter 7 Technical Notes 8. Lookarounds Positive Lookaheads Negative Lookaheads Positive Lookbehinds Negative Lookbehinds What You Learned in Chapter 8 Technical Notes 9. Marking Up a Document with HTML Matching Tags Transforming Plain Text with sed Substitution with sed Handling Roman Numerals with sed Handling a Specific Paragraph with sed Handling the Lines of the Poem with sed Appending Tags Using a Command File with sed Transforming Plain Text with Perl Handling Roman Numerals with Perl Handling a Specific Paragraph with Perl Handling the Lines of the Poem with Perl Using a File of Commands with Perl What You Learned in Chapter 9 Technical Notes 10. The End ofthe Beginning Learning More Notable Tools, Implementations, and Libraries Perl PCRE Ruby (Oniguruma) Python RE2 Matching a North American Phone Number Matching an Email Address What You Learned in Chapter 10 Appendix: Regular Expression Reference Regular Expression Glossary Index
章节摘录
版权页: 插图: Capturing Groups and Back References You'll now match just a portion of the phone number using what is known as a cap-turing group. Then you'll refer to the content of the group with a backreference. Tocreate a capturing group, enclose a \d in a pair of parentheses to place it in a group,and then follow it with a \1 to backreference what was captured: (\d)\d\1. The \1 refers back to what was captured in the group enclosed by parentheses. As aresult, this regular expression matches the prefix 707. Here is a breakdown of it: (\d) matches the first digit and captures it (the number 7) \d matches the next digit (the number 0) but does not capture it because it is notenclosed in parentheses \1 references the captured digit (the number 7) This will match only the area code. Don't worry if you don't fully understand this rightnow. You'll see plenty of examples of groups later in the book. You could now match the whole phone number with one group and severalbackreferences: (\d)0\1\D\d\d\1\D\1\d\d\d But that's not quite as elegant as it could be. Let's try something that works even better. Using Quantifiers Here is yet another way to match a phone number using a different syntax:The numbers in the curly braces tell the regex processor exactly how many occurrencesof those digits you want it to look for. The braces with numbers are a kind of quanti-fier. The bracesthemselves are considered metacharacters.
编辑推荐
《正则表达式入门(影印版)(英文版)》了解正则表达式是什么以及它们如何运作,掌握在命令行工具和多种编程语言中使用正则表达式的差异,运用简单方法在文本中寻找模式,包括数字、字母、Unicode字符和字符串,学习如何使用零宽度断言和通配符,运用组、反向引用、字符类和量词,使用正则表达式在HTML5中标记纯文本。
图书封面
图书标签Tags
无
评论、评分、阅读与下载