Tecnologia
Pocket Reference
SECOND EDITION
Regular Expression
Pocket Reference
Tony Stubblebine
Beijing • Cambridge • Farnham • Köln • Paris • Sebastopol • Taipei • Tokyo
Regular Expression Pocket Reference, Second Edition
by Tony Stubblebine
Copyright © 2007, 2003 Tony Stubblebine. All rights reserved. Portions of
this book are based on Mastering RegularExpressions, by Jeffrey E. F. Friedl,
Copyright © 2006, 2002, 1997 O’Reilly Media, Inc.
Printed in Canada.
Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North,
Sebastopol, CA 95472.
O’Reilly books may be purchased for educational, business, or sales
promotional use. Online editions are also available for most titles
(safari.oreilly.com). For more information, contact our corporate/institutional sales department: (800) 998-9938 or corporate@oreilly.com.
Editor: Andy Oram
Production Editor: Sumita Mukherji
Copyeditor: Genevieve d’Entremont
Indexer: Johnna VanHoose Dinse
Cover Designer: Karen Montgomery
Interior Designer: David Futato
Printing History:
August 2003:
July 2007:
First Edition.
Second Edition.
Nutshell Handbook, the Nutshell Handbook logo, andthe O’Reilly logo are
registered trademarks of O’Reilly Media, Inc. The Pocket Reference series
designations, Regular Expression Pocket Reference, the image of owls, and
related trade dress are trademarks of O’Reilly Media, Inc.
Many of the designations used by manufacturers and sellers to distinguish
their products are claimed as trademarks. Where those designations appear
in this book, andO’Reilly Media, Inc. was aware of a trademark claim, the
designations have been printed in caps or initial caps.
Java™ is a trademark of Sun Microsystems, Inc. Microsoft Internet Explorer
and .NET are registered trademarks of Microsoft Corporation. Spider-Man
is a registered trademark of Marvel Enterprises, Inc.
While every precaution has been taken in the preparation of this book, thepublisher and author assume no responsibility for errors or omissions, or for
damages resulting from the use of the information contained herein.
ISBN-10: 0-596-51427-1
ISBN-13: 978-0-596-51427-3
[T]
Contents
About This Book
1
Introduction to Regexes and Pattern Matching
Regex Metacharacters, Modes, and Constructs
Unicode Support
3
5
13
Regular Expression Cookbook
Recipes13
14
Perl 5.8
Supported Metacharacters
Regular Expression Operators
Unicode Support
Examples
Other Resources
16
17
21
23
24
25
Java (java.util.regex)
Supported Metacharacters
Regular Expression Classes and Interfaces
Unicode Support
Examples
Other Resources
26
26
30
35
36
38
v
.NET and C#
Supported Metacharacters
Regular Expression Classes andInterfaces
Unicode Support
Examples
Other Resources
38
38
42
47
47
49
PHP
Supported Metacharacters
Pattern-Matching Functions
Examples
Other Resources
50
50
54
56
58
Python
Supported Metacharacters
re Module Objects and Functions
Unicode Support
Examples
Other Resources
58
58
61
64
65
66
RUBY
Supported Metacharacters
Object-Oriented Interface
Unicode SupportExamples
66
67
70
75
75
JavaScript
Supported Metacharacters
Pattern-Matching Methods and Objects
Examples
Other Resources
77
77
79
82
83
vi |
Contents
PCRE
Supported Metacharacters
PCRE API
Unicode Support
Examples
Other Resources
83
84
89
92
92
96
Apache Web Server
Supported Metacharacters
RewriteRule
Matching Directives
Examples
96
96
99102
102
vi Editor
Supported Metacharacters
Pattern Matching
Examples
Other Resources
103
103
106
108
108
Shell Tools
Supported Metacharacters
Other Resources
109
109
114
Index
115
Contents |
vii
Regular Expression Pocket
Reference
Regular expressions are a language used for parsing and
manipulating text. They are often used to perform complex...
Regístrate para leer el documento completo.