Regular Expression - The University of Edinburgh

[Pages:128] Regular Expression

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 Regular Expressions, 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.). For more information, contact our corporate/ institutional sales department: (800) 998-9938 or corporate@.

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, and the 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, and O'Reilly Media, Inc. was aware of a trademark claim, the designations have been printed in caps or initial caps.

JavaTM 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, the publisher 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

3

Regex Metacharacters, Modes, and Constructs

5

Unicode Support

13

Regular Expression Cookbook

13

Recipes

14

Perl 5.8

16

Supported Metacharacters

17

Regular Expression Operators

21

Unicode Support

23

Examples

24

Other Resources

25

Java (java.util.regex)

26

Supported Metacharacters

26

Regular Expression Classes and Interfaces

30

Unicode Support

35

Examples

36

Other Resources

38

v

.NET and C#

38

Supported Metacharacters

38

Regular Expression Classes and Interfaces

42

Unicode Support

47

Examples

47

Other Resources

49

PHP

50

Supported Metacharacters

50

Pattern-Matching Functions

54

Examples

56

Other Resources

58

Python

58

Supported Metacharacters

58

re Module Objects and Functions

61

Unicode Support

64

Examples

65

Other Resources

66

RUBY

66

Supported Metacharacters

67

Object-Oriented Interface

70

Unicode Support

75

Examples

75

JavaScript

77

Supported Metacharacters

77

Pattern-Matching Methods and Objects

79

Examples

82

Other Resources

83

vi | Contents

PCRE

83

Supported Metacharacters

84

PCRE API

89

Unicode Support

92

Examples

92

Other Resources

96

Apache Web Server

96

Supported Metacharacters

96

RewriteRule

99

Matching Directives

102

Examples

102

vi Editor

103

Supported Metacharacters

103

Pattern Matching

106

Examples

108

Other Resources

108

Shell Tools

109

Supported Metacharacters

109

Other Resources

114

Index

115

Contents | vii

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download