来自正则表达式大师的作品

原创 2005年02月26日 19:40:00
Introduction to Regular Expressions Here's the scenario: you're given the job of checking the pages on a web server for doubled words (such as "this this"), a common problem with documents subject to heavy editing. Your job is to create a solution that will: Accept any number of files to check, report each line of each file that has doubled words, highlight (using standard ANSI escape sequences) each doubled word, and ensure that the source filename appears with each line in the report. Work across lines, even finding situations where a word at the end of one line is repeated at the beginning of the next. Find doubled words despite capitalization differences, such as with 'The the···', as well as allow differing amounts of whitespace (spaces, tabs, newlines, and the like) to lie between the words. Find doubled words even when separated by HTML tags. HTML tags are for marking up text on World Wide Web pages, for example, to make a word bold: '···it is very very important···'. That's certainly a tall order! But, it's a real problem that needs to be solved. At one point while working on the manuscript for this book, I ran such a tool on what I'd written so far and was surprised at the way numerous doubled words had crept in. There are many programming languages one could use to solve the problem, but one with regular expression support can make the job substantially easier. Regular expressions are the key to powerful, flexible, and efficient text processing. Regular expressions themselves, with a general pattern notation almost like a mini programming language, allow you to describe and parse text. With additional support provided by the particular tool being used, regular expressions can add, remove, isolate, and generally fold, spindle, and mutilate all kinds of text and data. It might be as simple as a text editor's search command or as powerful as a full text processing language. This book shows you the many ways regular expressions can increase your productivity. It teaches you how to think regular expressions so that you can master them, taking advantage of the full magnitude of their power. A full program that solves the doubled-word problem can be implemented in just a few lines of many of today's popular languages. With a single regular-expression search-and-replace command, you can find and highlight doubled words in the document. With another, you can remove all lines without doubled words (leaving only the lines of interest left to report). Finally, with a third, you can ensure that each line to be displayed begins with the name of the file the line came from. We'll see examples in Perl and Java in the next chapter. The host language (Perl, Java, VB.NET, or whatever) provides the peripheral processing support, but the real power comes from regular expressions. In harnessing this power for your own needs, you learn how to write regular expressions to identify text you want, while bypassing text you don't. You can then combine your expressions with the language's support constructs to actually do something with the text (add appropriate highlighting codes, remove the text, change the text, and so on).

Jmeter中正则表达式提取器使用详解

转载地址:http://blog.csdn.net/quiet_girl/article/details/50724313 在使用Jmeter过程中,会经常使用到正则表达式提...
  • wanglha
  • wanglha
  • 2016-03-02 17:15:04
  • 44411

原创的转载(转自曾经的CSDN第一名博主)

转载:来自CSDN第一名博主:http://blog.csdn.net/phphot/article/details/2187505                         ...
  • carter_yu
  • carter_yu
  • 2016-01-19 18:22:03
  • 1266

一年成为Emacs高手(像神一样使用编辑器)

作者:陈斌(redguardtoo) 版本号:20140329 更新时间: 2014-03-29 Sat 原创时间: 2012-01-31 Tue 版权:本文采用以下协议进行授权,自由转载 - 非商用...
  • redguardtoo
  • redguardtoo
  • 2012-01-31 16:35:12
  • 504872

ppt动画大师的作品

  • 2014年04月16日 11:29
  • 14.67MB
  • 下载

Adobe Illustrator大师班 经典作品与完美技巧赏析.pdf

  • 2015年07月26日 17:43
  • 22.92MB
  • 下载

java 正则表达式

.2013中国大数据大会赠票申请        文思海辉第一届在线编程大赛      消灭0回答,赢下载分      订阅CSDN社区周刊,及时了解社区精华内容      办公大师系列经典丛书 诚聘译...
  • liu22985342
  • liu22985342
  • 2013-12-02 14:30:21
  • 593

建筑大师柯布西耶15个经典作品的Sketchup模型

  • 2015年11月07日 22:32
  • 30.39MB
  • 下载

大师作品sketchup模型29个

  • 2015年09月25日 11:08
  • 391KB
  • 下载

一年成为Emacs高手(像神一样使用编辑器)http://blog.csdn.net/redguardtoo/article/category/1282870

作者: 陈斌(redguardtoo) 版本号: 20130801 更新时间:  原创时间: [2012-01-31 周二 15:08] 版权:本文采用以下协议进行授权, 自由...
  • robertzhouxh
  • robertzhouxh
  • 2013-10-17 16:33:19
  • 4382

大师的审美、观点与论断

1. 读城记 林语堂称紫禁城为“极禁城”;
  • lanchunhui
  • lanchunhui
  • 2016-12-22 15:29:27
  • 218
收藏助手
不良信息举报
您举报文章:来自正则表达式大师的作品
举报原因:
原因补充:

(最多只允许输入30个字)