精通正则表达式:英文本

精通正则表达式:英文本
作 者: Jeffrey Friedl
出版社: 东南大学出版社
丛编项: 东南大学出版社O'Reilly图书系列
版权说明: 本书为公共版权或经版权方授权,请支持正版图书
标 签: perl
ISBN 出版时间 包装 开本 页数 字数
未知 暂无 暂无 未知 0 暂无

作者简介

暂缺《精通正则表达式:英文本》作者简介

内容简介

正则表达式是一种用来操作文本和数据的强大工具。近年来,它们快速广泛传播,并被多种流行工具和语言作为标准特性提供,如Perl、Java、VB.NET、C#(及任何使用.NET框架的语言)、PHP、Python、Ruby、Tcl、MySQL、awk、Emacs等。 如果还未使用过正则表达式,从本书中您将发现一个掌控数据的全新世界。如果使用过它们,您将会充分意识到本书空前的深度和广度。如果您认为自己已经掌握了所有需要掌握的正则表达式知识,本书将让您大开眼界。 尽管正则表达式具有易用、灵活、功能强大的优点,但我们往往未能充分利用它们。正则表达式可以将那些原本复杂且繁琐的文本处理过程变成可自动处理的工作。正则表达式能够为您节省时间、减少烦恼。它们可以用来为大量问题编制出一流的解决方案。 正则表达式是一项重要技术。然而,在专家手中强大的工具同样会因为使用上的不慎而带来危险。《精通正则表达式》能够帮助您跨越雷区,成为专家。一旦掌握了正则表达式,它们将成为您的工具箱中极其重要、不可或缺的一部分。 《精通正则表达式(第二版)》已被全面更新,涵盖了Perl 5.8及其他诸如Java、VB.NET、C#、Python、JavaScript、Tcl、Ruby等语言提供的全部新特性。本书用明晰、轻快的文笔,将原本复杂、乏味的主题清楚明白地展现在数以千计的程序员面前,并辅以一些真实世界中复杂问题的解决方案。《精通正则表达式》提供了大量可供直接使用的信息。 本书的主题包括:· 多种语言和工具不同版本之间的特性比较· 正则表达式引擎的工作机制· 优化(提供主要方法)· 如何精确匹配· 针对特定语言的探讨

图书目录

Preface

1:Introductionc to Regular Expressions

Solving Real Problems

Regular Expressions as a Language

The Filename Analogy

The Language Analogy

The Regular-Expression Frame of Mind

If You Have Some Regular-Expression Experience

Searching Text Files:Egrep

Egrep Metacharacters

Start and End of the Line

Character Classes

Matching Any Character with Dot

Alternation

Ignoring Differences in Capitalization

Word Boundaries

In a Nutshell

Optional Items

Other Quantifiers:Repetition

Parentheses and Backreferences

The Great Escape

Expanding the Foundation

Linguistic Diversification

The Goal of a Regular Expression

A Few More Examples

Regular Expression Nomenclature

Improving on the Status Quo

Summary

Personal Glimpses

3:Extended Introductory Examples

About the Examples

A Short Introductioncto Perl

Matching Text with Regular Expressions

Toward a More Real-World Example

SidecEffects of a Successful Match

Intertwined Regular Expressions

Intermission

Modifying Text with Regular Expressions

Example: FormcLetter

Example:Prettifying a Stock Price

Automated Editing

A Small Mail Utility

Adding Commas to a Number with Lookaround

Text-to-HTML Conversion

That Doubled-Word Thing

3:Overview of Regular Expression Features and Flavors

A Casual Stroll Across the Regex Land scape

The Origins of Regular Expressions

At a Glance

Care and Handling of Regular Expressions

Integrated Handling

Procedural and Object-Oriented Handling

A Search-and-Replace Example

Search and Replace in Other Languages

Care and Handling:Summary

Strings,Character Encodings,and Modes

Strings as Regular Expressions

Character-Encoding Issues

Regex Modes and Match Modes

Common Metacharacters and Features

Character Representations

Character Classes and Class-L1ke Constructs

Anchors and other“Zero-Width Assertions”

Comments and Mode Modifiers

Grouping,Capturing,Conditionals,and Control

Guide to the AdVanced Chapters

4:The Mectanics of Exptession Protessing

Start Your Engines!

Two Kinds of Engines

New Standards

Regex Engine Types

From the Department of Redundancy Department

Testing the Engine Type

Match Basics

About the Examples

Rule l:The Match That Begins Earliest Wirls

Engine Pieces and Parts

Rule 2:The Standard Quantifiers Are Greedy

Regex-Directed Versus Text-Directed

NFA Engine:Regex-Directed

DFA Engine:Text-Directed

First ThOLIghts:NFA and DFA in Comparison

Backtracking.

A Really Crummy Analogy

Two Important Points on Backtracking

Saved States

Backtracking and Gteediness

More About Greediness and Backtracking

Problems of Gteediness.

Multi-Character“Quotes”

Using Lazy Qnantifiers

Greediness and Laziness Always Favor a Match

The Essence of Greediness,Laziness,and Backtracking.

Possessive Quantifiers and Atomic Grouping

Possessive Quantifiers,?+,★+,++,and{m,n}+

The Backtracking of Lookaround

Is Alternation Greedy?

Taking Advantage of ordered Alternation

NFA.DFA.and POSIX

“The Longest.Leftmost”

PoSIX and the Longest-Leftmost Rule

Speed and Efficiency

Summary:NFA and DFA in Comparison

Summary

5:Practical Regex Techniques

Regex Balancing Act

A Few Shon Examples

Continuing With Continuation Lines

Matching an IP Addtess

Working With Filenames

Matching Balanced Sets of Parentheses

Watching Out for Unwanted Matches

Matching Delimited Text

Knowing Your Data and Making Assumptions

Stripping Leading and Trailing Whitespace

HTML-Related Examples

Matching an HTML Tag

Matching an HTML Link

Examining an HTTP URL

Validating a Hostname

P1ucking out a URL in the Real World

Extended Examples

Keeping in Sync With Your Data

Parsing CSV Files

6: Crafting an Efficient Expression

A Sobering Example

A Simple Change-Placing Your Best Foot Forvcard

Efficiencv Ve-rses Correctness

Advancing Further--Localizing the Greediness

RealitV Check

A Global VieW of Backtracking

More Work for a PoSIX NFA

Work Required During a Non-Match

Being More Specific.

A1ternation Can Be Exoensive

Benchmarking

Know What You're Measuring

Benchmarking With Java

Benchmarking With VB.NET

Benchmarking With Python

Benchmarking With Ruby

Benchirlarking With Tcl

Common optimizations

No Free Lurich

Evervone’s Lunch is Dfifetent

The Mechailics of Regex Application

Pre-Application Optimizations

Optimizations With the Transmission

Optimizations of the Regex Itself

Techniques for Faster Expressions

Common Sense Techniques

Expose Literal Text

Expose Anchors

Lazy Versus Greedy:Be Specific

Split Into Multiple Regular Expressions

Mimic Initial-Character DiscriminaCion

use Atomic Grouping and Possessive Quantifiers

Lead the Engine to a Match

Unrolling the Loop

Method 1:Building a Regex From Past Experiences

The Real“Unrolling-the-Loop”Panern

Method 2:A ToD-Down View

Method 3:An Internet Hostname

observations

using Atomic Gtonping and PossessiVe Quantifiers

Short Unrolling Examples

Unrolling C Comments

The Freenowing Regex

A Helping Hand to Guide the Match

A Well-Guided Regex is a Fast Regex

Wrapup

In Summarg:Think!

7:Perl

ReguIar Expressi0128 as a Language Component

Perl’s Greatest Strength

Perl’s Greatest Weakness

Pefl’s Regex Flavor.

Regex operands and Regex Literals

HOW Regex Literals Are Parsed

Regex Modifiers

Regex-Related Perlisms

Expression ConteXt

Dynamic SCOpe and Regex Match Effects

Special Variables Modi6ed by a Match

The qr//operator and Regex objectS

Building and Using Regex objects

Viewing Regex objects

Using Regex objectS for Efficiency

The Match operator

Match’s Regex operand

Specifying the Match Target operand

Diffetent Uses of the MatCh 0perator

Iterative Matching:Scalar Context,with/g

The Match operator's Environmental Relations

The Substitution operator

The Replacement operand

The/e Modifier

Context and Return Value

The Split Operator

Basic Split

Returning Empty Elements

Split’s Special Regex operands

Split’s Match operand with Capturing Parentheses

Fun with Perl Enhancements

Using a Dynamic Regex to Match Nested Pair5

Using the Embedded-Code C01"18truct

Using local jn an Embedded-Code Construct

A Warrling About Embedded Code and my Variables.

Matching Nested Constrtlcts with Enlbedded Code

overloading Regex Literals

Probleros with Regex-Ljteral overJoading

Minlicking Named Capture

Perl Efficiency Issues

“There's More Than one Way to Do It”

Regex Compilation,the/o Modifier qr//,and Efficiency.

Understanding the“Pre-Match”Copy

The Study Function

Benchmarking

Regex Debugging Information

Final Comments

8:Java

Judging a Regex Package

Technical Issues

Social and Political Issues

Obiect Models

A Few AbstraCt obiect Models

Growing Complexity

Packages,Packages,Packages

Why So Many“Perl5”Flavors?

Lies.Damn Lies.and Benchmarks

Recommendations

Sun’s Regex Package

Regex Flavor

using java.util.regex

The Pattern.compile()Factory

The Matcher Obiect

other Pattern Methods

A Quick Look at Jakarta一ORO

ORO’s Perl5Util

A Mini Perl5Util Reference

Using ORO’s Underlying Classes

9: NET

.NET’s Regex Flavor

Additional Comments on the Flavor

Using.NET Regular Expressions

Regex Quickstart

Package overview

Core obiect overview

Core Object Details

Creating Regex Objects

Using Regex Objects

Using Match Objects

Using Group Objects

Static "Convenience" Functions

Regex Caching

Support Functions

Advanced .NET

Regex Assemblies

Matching Nested Constructs

Capture Objects

Index