Regular Expression Guide (2nd Edition) cover

Regular Expression Guide (2nd Edition)

Rating 4.2
Word count
180K words
Chapters
123
ISBN
9787121351303

Tags

Summary

Drawing on the author's own practical problems and the questions other developers have brought to him, this book distills a set of ingenious ways to use regular expressions and guides readers, through concrete examples, in breaking down and analyzing problems. It is divided into three parts: Part One explains the fundamentals of regular expressions, covering the common features and constructs found in them; Part Two goes deeper into regular expressions, exploring encoding issues, matching principles, and problem-solving approaches in detail; Part Three puts all the preceding knowledge into practice in commonly used languages—.NET, Java, JavaScript, PHP, Python, Ruby, Objective-C, and Golang—explaining the specific usage of regular expressions in each and teasing out the subtle differences between versions. The book can serve both as a dedicated course of study and as a reference manual for looking things up. It is suited to technical professionals who frequently work with text (such as log analysis or network operations), programmers familiar with common development languages, and readers who already have some understanding of regular expressions.

Editor's review

Regular Expressions: A Guide (2nd Edition) is Yu Sheng's 2018 technical book on regular expressions and a comprehensive upgrade of the first edition, systematically laying out the core concepts, syntax rules, and practical techniques of regular expressions. The author, Yu Sheng, combines technical depth with teaching experience—he has translated Mastering Regular Expressions—and writes in a clear, rigorous style that emphasizes the connection between principle and practice.

The book's value lies in its distinctive "guide" positioning: it is not merely a syntax manual but stresses the design thinking and problem-solving patterns behind regular expressions. Through numerous cases drawn from realistic scenarios (such as text parsing, data extraction, and input validation), it gradually leads readers to understand how the regex engine works and to avoid common pitfalls. The second edition adds modern topics including Unicode, performance optimization, and differences in regular expression support across popular programming languages (such as Python, JavaScript, and Java), making the content better attuned to today's development environment.

From an editorial perspective, the book's standout strength is its balance: it both dissects the underlying logic of regular expressions (such as backtracking and greedy/lazy matching) and provides practical examples ready for immediate use. The chapters progress from shallow to deep, each ending with a summary and exercises, making it suitable for systematic study. For developers, test engineers, and data analysts who frequently process text or data, this book helps build solid regex thinking and improve both efficiency and code quality.

Who it's for

A good fit for

  • Software developers who frequently need to extract, clean, or validate text
  • Technical learners who want to master the principles of regular expressions systematically and avoid fragmented learning
  • Data workers who need efficient pattern matching in scenarios such as data analysis and log processing
  • Advanced users with a foundation who want to understand advanced features in depth (such as backtracking control and Unicode support)

Not a good fit for

  • Light, casual users who only need simple find-and-replace and have no need for deep study
  • Readers who expect to quickly master "universal regex formulas" without wanting to understand the underlying mechanisms

Reading tips

  1. Read the chapters in order, focusing on the core syntax and engine mechanisms in Chapters 2–4, which are the foundation for later application
  2. When practicing, tie the material to your own work scenarios and try adapting the book's cases to real tasks—for example, using regex to optimize existing scripts
  3. When reading Chapter 8, "Performance Optimization," use tools to test the matching efficiency of different formulations and deepen your understanding of backtracking issues

About the publisher

Publishing House of Electronics Industry China · Founded in 1982

The Publishing House of Electronics Industry is a comprehensive publisher distinguished by its focus on electronic information and related fields. Judging from the more than 3,000 titles in its catalogue, its publishing covers programming and design, artificial intelligence, computer science, finance and economics, photography, and social sciences, attending both to cutting-edge technology and to general readers. Representative titles include Factor Investing: Methods and Practice, x86 Assembly Language: From Real Mode to Protected Mode, The RISC-V Reader, Artificial Intelligence: Speech Recognition, Understanding and Practice, Phased Array Radar Technology, Radar Target Characteristics, and 100 Go Mistakes and How to Avoid Them, most of which centre on technical methods and engineering practice. Its authors include Shi Chuan, Li Zhong, Wang Xiaobo, David Patterson, Andrew Waterman, and Yu Zihao, among others from China and abroad. Owing to limited public information, no further publishing features are elaborated here.

Contents

  1. 版权信息
  2. 内容简介
  3. 引子:关于正则表达式……
  4. 返璞归真——评《正则指引》
  5. 克制我们内心的冲动
  6. 前言
  7. 第一部分
  8. 第1章 字符组
  9. 1.1 普通字符组
  10. 1.2 关于Python的基础知识
  11. 1.3 普通字符组(续)
  12. 1.4 元字符与转义
  13. 1.5 排除型字符组
  14. 1.6 字符组简记法
  15. 1.7 字符组运算
  16. 1.8 POSIX字符组
  17. 第2章 量词
  18. 2.1 一般形式
  19. 2.2 常用量词
  20. 2.3 数据提取
  21. 2.4 点号
  22. 2.5 滥用点号的问题
  23. 2.6 忽略优先量词
  24. 2.7 转义
  25. 第3章 括号
  26. 3.1 分组
  27. 3.2 多选结构
  28. 3.3 引用分组
  29. 3.4 非捕获分组
  30. 3.5 补充
  31. 第4章 断言
  32. 4.1 单词边界
  33. 4.2 行起始/结束位置
  34. 4.3 环视
  35. 4.4 补充
  36. 第5章 匹配模式
  37. 5.1 不区分大小写模式与模式的指定方式
  38. 5.2 单行模式
  39. 5.3 多行模式
  40. 5.4 注释模式
  41. 5.5 补充
  42. 第6章 其他
  43. 6.1 转义
  44. 6.2 正则表达式的处理形式
  45. 6.3 表达式中的优先级
  46. 6.4 回车和换行
  47. 第二部分
  48. 第7章 Unicode
  49. 7.1 基础知识
  50. 7.2 关于编码
  51. 7.3 尽量使用Unicode编码
  52. 7.4 Unicode与字符组简记法
  53. 7.5 规范化问题
  54. 7.6 单词边界
  55. 7.7 码值转义序列
  56. 7.8 Unicode属性
  57. 7.9 Unicode属性列表
  58. 7.10 POSIX字符组
  59. 7.11 Emoji
  60. 第8章 匹配原理
  61. 8.1 有穷自动机
  62. 8.2 正则表达式的匹配过程
  63. 8.3 回溯
  64. 8.4 NFA和DFA
  65. 第9章 常见问题的解决思路
  66. 9.1 关于元素的三种逻辑
  67. 9.2 正则表达式的常见操作
  68. 9.3 正则表达式的优化建议
  69. 9.4 别过分依赖正则表达式
  70. 第三部分
  71. 第10章 .NET
  72. 10.1 预备知识
  73. 10.2 正则功能详解
  74. 10.3 正则API简介
  75. 10.4 常用操作示例
  76. 第11章 Java
  77. 11.1 预备知识
  78. 11.2 正则功能详解
  79. 11.3 正则API简介
  80. 11.4 常用操作示例
  81. 11.5 Java 8和Java 9的新改进
  82. 第12章 JavaScript
  83. 12.1 预备知识
  84. 12.2 正则功能详解
  85. 12.3 正则API简介
  86. 12.4 常用操作示例
  87. 12.5 关于ActionScript
  88. 第13章 PHP
  89. 13.1 预备知识
  90. 13.2 正则功能详解
  91. 13.3 正则API简介
  92. 13.4 常见的正则操作举例
  93. 第14章 Python
  94. 14.1 预备知识
  95. 14.2 正则功能详解
  96. 14.3 正则API简介
  97. 14.4 常用操作示例
  98. 第15章 Ruby
  99. 15.1 预备知识
  100. 15.2 正则功能详解
  101. 15.3 正则API简介
  102. 15.4 常用操作示例
  103. 15.5 Ruby 1.9的新变化
  104. 第16章 Objective-C
  105. 16.1 预备知识
  106. 16.2 正则功能详解
  107. 16.3 正则API简介
  108. 16.4 常用操作示例
  109. 第17章 Golang
  110. 17.1 预备知识
  111. 17.2 正则功能详解
  112. 17.3 正则API简介
  113. 17.4 常用操作示例
  114. 第18章 Linux/UNIX
  115. 18.1 POSIX
  116. 18.2 vi
  117. 18.3 grep
  118. 18.4 awk
  119. 18.5 sed
  120. 18.6 总结
  121. 附录A 常用语言中正则特性一览
  122. 附录B 常用的正则表达式
  123. 附录C 常用的正则表达式工具及资源

FAQ

Is this book suitable for complete beginners?
The book starts from basic syntax but moves at a fairly quick pace, so it is better suited to readers with some programming experience or prior exposure to regular expressions. Complete beginners can read the first two chapters first and practice hands-on.
Which language are the code examples mainly in?
The examples mainly use cross-language general regex syntax, with key chapters supplementing the implementation differences in languages such as Python, JavaScript, and Java, focusing on concepts rather than binding to a specific language.
What important updates does the second edition have compared with the first?
The second edition adds topics on Unicode handling and performance optimization, updates the regex support in modern programming languages, and rewrites some chapters to explain engine principles more clearly.

Related on WeRead

Comments

Find this book

This site is an index: you start “Search all sources” in your browser, and the entries it lists all point to third-party sites; please judge their availability yourself.

About the author

余晟 Author

Yu Sheng is a Chinese author of technical books. Public information about him is limited, and his nationality, dates of birth and death, and educational background are not known. One of his works is held in the collection: Regular Expressions Guide (2nd Edition), a book commonly classified under programming and design. Judging from the subject, he focuses on regular expressions, a practical technology widely used in text processing and software development. His writing tends toward reference and learning guides, emphasizing conceptual clarity and rule explanation rather than general programming philosophy. The existence of a second edition indicates that the book has been revised and updated, suggesting continued relevance and reader demand. For readers who want to learn regular expressions systematically, such a work can serve as a reference for consultation and practice. Because no other information about the author is publicly available, a fuller picture of his work still requires more material.

More by the same author

Top rated in the same category