Regular Expression Recipes for Windows Developers: A Problem-Solution Approach

Front Cover
Apress, Nov 3, 2006 - Computers - 400 pages

Regular expressions are an essential part of programming, but they can be difficult to cope with. Enter Regular Expression Recipes for Windows Developers. This is the only book of its kind that presents material in a functional, concise manner. It contains over 100 of the most popular regular expressions, along with explanations of how to use each one. It also covers all of the major development languages, including JavaScript, VB, VB .NET, and C#.

Author Nathan A. Good teaches by example and provides concise syntax references as necessary throughout the book. You’re sure to find his examples accurate and relevant. This book is an ideal solutions guide for you to keep in a handy place for quick reference.

 

What people are saying - Write a review

We haven't found any reviews in the usual places.

Contents

12 Finding Words
6
13 Finding Multiple Words with One Search
10
14 Finding Variations on Words
14
16 Replacing Words
22
17 Replacing Everything Between Two Delimiters
25
18 Replacing Tab Characters
29
111 Searching for Repeated Words Across
40
112 Searching for Lines Beginning with a Word
43
49 Limiting User Input to 15 Characters
186
See Also 19 23 37 38 41424344 45 48 410
189
412 Validating US Phone Numbers
198
413 Validating US Social Security Numbers
202
See Also 2122 2341424344 45 46 48 411 412 413
214
418 Extracting Usernames from
224
419 Extracting Country Codes from
227
420 Reformatting Peoples Names
230

113 Searching for Lines Ending with a Word
47
116 Filtering Profanity
57
118 Escaping Quotes
64
119 Removing Escaped Sequences
67
120 Adding Semicolons at the End of a Line
69
121 Adding to the Beginning of a Line
72
122 Replacing Smart Quotes with
76
Private Shared Regex As Regex Mew Regex u201c u2014
77
125 Joining Lines in a File
85
126 Removing Everything on a Line After a
88
URLs and Paths
91
21 Extracting the Scheme from a URI
92
22 Extracting Domain Labels from URLs
95
23 Extracting the Port from a URL
99
25 Extracting Query Strings from URLs
106
Private Shared Regex As Regex Mew Regex ? ?queryx++
107
27 Extracting the Drive Letter
113
This is where depending on the purpose it might be
122
CSV and TabDelimited Files
127
32 Finding Valid TabDelimited Records
132
33 Changing CSV Files to TabDelimited Files
135
34 Changing TabDelimited Files to CSV Files
139
14 ? which
145
36 Extracting TabDelimited Fields
146
Formatting and Validating
155
41 Formatting US Phone Numbers
156
See Also 2122 2341424344 45 46 48 411 412 413
159
42 Formatting US Dates
160
44 Formatting Large Numbers
168
See Also 17 120 26 46
170
45 Formatting Negative Numbers
171
See Also 17 120 26 44
177
48 Validating US Currency
182
See Also 15 19 2122 27 411
233
422 Validating Affirmative Responses
238
HTML and XML
243
found any number of times
246
Note In this example Im assuming that the text being
253
?
256
55 Adding an HTML Attribute
257
56 Removing Whitespace from HTML
260
57 Escaping Characters for HTML
262
58 Removing Whitespace from CSS
265
This recipe explicitly matches JavaScript script tags but you can
270
Source Code
271
64 Changing a Method Name
283
65 Removing Inline Comments
286
66 Commenting Out Code
289
To make this regex work with VBstyle and VBScriptstyle comments
291
67 Matching Variable Names
292
Alternatively you can replace the digit range 09 with the
295
69 Searching for Words Within Comments
301
610 Finding NET Namespaces
304
611 Finding Hexadecimal Numbers
307
or
313
613 Setting a SQL Owner
314
615 Changing Null Comparisons
321
O
324
616 Changing NET Namespaces
325
617 Removing Whitespace in Method Calls
328
O
330
618 Parsing CommandLine Arguments
331
619 Finding Words in Curly Braces
334
620 Parsing Visual Basic NET Declarations
337
624 Setting the Assembly Version
351
Copyright

Other editions - View all

Common terms and phrases

About the author (2006)

Nathan A. Good lives in the Twin Cities areaof Minnesota. He is a contractor with Alliance of Computer Professionals in Bloomington. When he isn't writing software, Nathan enjoys building PCs and servers, reading about and working with new technologies, and trying to get all his friends to make the move to open source software. When he's not at a computer (which he admits is not often), he spends time with his family, at his church, and at the movies.

Bibliographic information