Mastering Regular Expressions,3rd
2007年07月26日 原创, 好书, 翻译
下面简单谈一谈《MRE3》和《BRE》相互比较的问题。
一、《MRE3》与《BRE》的共同点
《MRE3》与《BRE》的共同点主要体现在全书的策划组织上,即都是前半部分讲述正则表达式的基本原理、机制、概念、术语(配合例子),后半部分讲述正则表达式在常用的软件、工具和编程语言中的应用。
《BRE》共26章,前10章分别是:
第1章 正则表达式简介
第2章 正则表达式工具和使用方法
第3章 简单的正则表达式
第4章 元字符和修饰符
第5章 字符类
第6章 字符串、行和词的边界
第7章 正则表达式中的圆括号
第8章 向前查找和向后查找
第9章 正则表达式的敏感性和特殊性
第10章 说明和调试正则表达式
后16章分别是:
第11章 在 MICROSOFT WORD 中使用正则表达式
第12章 在 STAROFFICE/OPENOFFICE.ORG WRITER 中使用正则表达式
第13章 通过 FINDSTR 使用正则表达式
第14章 POWERGREP
第15章 MICROSOFT EXCEL 中的通配符
第16章 SQL SERVER 2000 中的正则表达式功能
第17章 在 MYSQL 中使用正则表达式
第18章 正则表达式与 MICROSOFT ACCESS
第19章 JSCRIPT 和 JAVASCRIPT 中的正则表达式
第20章 正则表达式与 VBSCRIPT
第21章 VISUAL BASIC .NET 与正则表达式
第22章 C# 和正则表达式
第23章 PHP 和正则表达式
第24章 W3C XML SCHEMA 中的正则表达式
第25章 JAVA 中的正则表达式
第26章 PERL 中的正则表达式
而《MRE3》的前6章分别是:
第 1 章 正则表达式简介
第 2 章 扩展性的例子
第 3 章 正则表达式的特性和风格概览
第 4 章 正则表达式处理机制
第 5 章 实用的 Regex 技术
第 6 章 编制有效的正则表达式
后4章分别是:
第 7 章 Perl 中的正则表达式
第 8 章 Java 中的正则表达式
第 9 章 .NET中的正则表达式
第 10 章 PHP 中的正则表达式
由以上列举的目录名中可以看出,《BRE》在前半部分(前10章)中主要讲述了正则表达式的基本概念,以及正则表达式中的字符类、元字符、修饰符、限定符、匹配位置的元字符、圆括号分组和反向引用、向前查找和向后查找等等与正则表达式有关的几乎全部基本概念--但没有讨论回溯与贪婪性的主题。同时,还介绍了正则表达式的敏感性与特殊性平衡问题,以及如何说明正则表达式(即为正则表达式添加注释)。
接下来,《BRE》用16章的宏大篇幅分别
- 介绍了如何在 Word、Excel、StarOffice.org Writer 等字表处理软件中的如何使用正则表达式(或通配符)功能完成常规的查找和替换操作;
- 介绍了使用 findstr、PowerGREP 等专门的文本搜索实用工具通过正则表达式高效地完成匹配文本的任务;
- 介绍了如何在 Access、MySQL、SQL Server 2000 等流行的关系型数据库中使用正则表达式语法(在 WHERE 子句中与 LIKE 或 REGEXP 关键字,或者 CONTAINS 谓词组合)筛选或搜索数据表(或全文索引)中的数据;
- 介绍了如何在 JavaScript/JScript 或 VBScript 脚本语言中使用与正则表达式有关的对象、集合、方法和属性完成基于 Web 的客户端文本验证任务(其中正则表达式模式对象或者基于字符串 String);
- 介绍了在主流面向对象的编程语言 VB.NET、C#、Java 中如何使用位于 System.Text.RegularExpressions 命名空间(前两种语言)或者 java.util.regex 包中的类的方法和属性使用完整甚至“超前”的正则表达式功能,在实际的编程项目中完成操纵文本任务;
- 介绍了服务器端脚本编程语言 PHP 中的 ereg() 和 preg() 两大函数族的强大正则表达式功能和怎样在正则表达式的最早引入者--Perl 脚本语言中,从容地对待同样简洁而隐秘的正则表达式和 Perl 语法,实现优雅漂亮的正则表达式功能。
- 还介绍了正则表达式在 W3C XML Schema 的 <xs:pattern /> 元素中如何用于限定元素及其属性的取值范围(及类型),以及 Unicode 字符类与字符块在 W3C XML Schema 中的应用。
而《MRE3》一开始用一章篇幅集中介绍了与正则表达式有关的基本知识:行的开始与结束边界、交替选择、反向引用、可选项目、重复限定、转义序列等。第二章在第一章基本概念的基础上结合扩展性的例子深入探讨了与正则表达式现实应用问题,包括:使用正则表达式匹配文本、使用正则表达式修改文本、自动编辑、小型邮件实用程序、通过定向查找为数字添加逗号、文本到 HTML 的转换、重复单词问题以及成功匹配的负作用等。第三章是为向第四章的核心主题过渡的一章,内容涉及正则表达式的起源、正则表达式面临的问题及解决方案以及锚点、“零宽度断言”和组、捕获、条件及控制等话题。第四章则深入到了正则表达式引擎的内部处理(匹配)机制,深入介绍了正则表达式引擎的类型(模式或文本主导)、匹配原则、状态保留、回溯与贪婪性、占有式限定符与原子组、POSIX 与最长最左规则以及速度和效率平衡的问题--这一章是正则表达式的核心所在。第五章则通过几个小例子、与 HTML 相关的例子以及扩展的例子验证了前几章中有关正则表达式的规则、机制和原理,巩固了对正则表达式基本原理和概念的理解。第六章中的内容涉及到与正则表达式有关的高级主题--如何编制有效的正则表达式。具体包括在平衡效率与准确性、全面理解回溯、性能测试和掌握常用优化技术以及加速正则表达式、掌握解除循环的基基础上构建流畅高效的正则表达式。
在书的后半部分,《MRE3》用4章的篇幅深入探讨了最完整、最全面的四种正则表达式实现--Perl、Java、.NET 和 PHP 中的正则表达式功能,并比较了相互之前的优缺点。对于 Perl 而言,其优势在于它的匹配操作符简洁而优雅,而且具有动态作用域等诸多特性;对于 Java,基正则表达式功能主要包含在 java.util.regex 包中,主要介绍了通过承担主要匹配任务的 Mather 类实现搜索、替换、拆分以及验证等常见任务;对于 .NET 而言,主要介绍了 Regex 对象、Match 对象、Group 对象以及 Capture 对象以及嵌套结构的内容;最后,对于 PHP,主要介绍了 Perl 兼容正则表达式模块 PCRE(Perl Compatible Regular Expressions)的函数族以及相关话题。
为之漫笔(李松峰),本博客专注于Web前后端技术、移动平台开发技术、交互设计和技术翻译。声明一下,因为时常需要外出审稿,而且基本不带笔记本,所以有时可能会迟一点回复大家的留言。
[...] 原来已经有细心热心(同时也在翻译正则表达式相关的书籍) 的朋友,对比了网上已经公布的《精通正则表达式》的片段,细细列出原文、我的译文和他的译文,并指出多处漏排和一处错译,另提出若干商榷之处。 [...]
Thank you for sharing!
This internet site is my aspiration, quite exceptional style and design and Perfect subject matter.
Whats up! I just wish to give an enormous thumbs up for the good data you’ve here on this post. I might be coming back to your weblog soon.
That is a great point to bring up. Thanks for the post.
I actually wanted to compose a small message to be able to express gratitude to you for the remarkable points you are giving here. My extended internet lookup has at the end of the day been honored with reasonable concept to go over with my good friends. I ‘d state that that many of us website visitors are extremely endowed to dwell in a magnificent network with so many awesome people with helpful methods. I feel somewhat lucky to have used your entire webpages and look forward to really more enjoyable minutes reading here. Thanks a lot once more for everything.
This really answered the downside, thank you!
very good post, i certainly love this website, keep on it
It’s hard to find knowledgeable people on this topic however you sound like you know what you’re talking about! Thanks
Your place is valueble for me. Thanks!…
I’m experiencing a problem with your rss feed . Don’t know why I am not able to subscribe to it. Is there anybody getting similar rss problem? Anyone who is aware of kindly respond. Thanks
You should take part in a contest for one of the best blogs on the web. I will recommend this web site!
I was very pleased to find this website. I wanted to thank you for your time for this wonderful post!! I definitely enjoy reading it and I have you bookmarked to check out new stuff you blog post.
I really relate to that post. Thanks for the info.
Thanks for spending the time to debate this, I really feel strongly about it and love reading more on this topic. If possible, as you grow to be an expert, would you mind updating your blog with more details?
Aw, this was a very nice post. In thought I wish to write like this – taking time and precise effort to make an excellent article is very rare…
It is highly helpful for me. Big thumbs up for this weblog post!
Would you be eager about exchanging hyperlinks?
Thanks for spending the time to debate this, I really feel strongly about it and love reading more on this topic. If attainable, as you turn into an expert, would you mind updating your weblog with more details?
More people need to read this and understand this aspect of the story. I cant believe you’re not more popular.
Moncler coat well-known, nevertheless in truth,Moncler b149, whether it’s a little overpriced. Whereby may i discover very affordable Moncler coat,Moncler b240, good top quality, in addition to would not hurt your wallet book importance products Moncler stores attributes in an exceedingly portion about the cost customary stores.
Coach Outlet Online is the best place to select new
given for long periods what they hardly dared hope to get once, are forever asking their mistresses for an account of the present, the past and even the future. As they get used to a mistress, they try to dominate