Regular Expressions

Glenn Stafford

Regular Expressions

Copy of Fortunes File

What Does The Following Mean?

Regular Expressions Defined

grep Command

fgrep Examples

Fixed String Example

egrep example

awk Command

AWK Process

AWK Process Continued

Record/Field Parsing

sed Command

Interpretation of Special Character Strings

^ Match At The Beginning Of A Line

$ Match At The End Of Line.

[LIST] Match A Single Character In A Specified List.

[^LIST] Negate Matching a Single Character In Specified List.

Combining Special Characters

. Match Any Single Character

* Repeat The Expression Zero Or More Times

+ Repeat Previous Expression One Or More Times

? REPEAT PREVIOUS EXPRESSION ZERO OR ONE TIME

() Grouping of Regular Expressions

| Union of Regular Expressions

Spanning Of Characters

Examples of Spanning Characters

Common Mistakes

Hit Or Miss

Cryptic RE Example

Results of Inelegant Expression

Common Matching Error

Useful One Liners

SED with Global Substitutions

Globally Replacing Pattern Matches

Why Should I Care About Regular Expressions?

PP Presentation

Awk Pattern Selection Method

/regular expression/ {statement(s)}

compound pattern {statement(s)}

pattern1,patern2 {statement(s)}

Regular Expression Examples

PERL Regular Expressions

Rename Tool (UNIX To DOS)

Regular Expression and Substituting

File Rename Example

Match Operator Example

Associative Array Example

Manipulating Associative Arrays

PERL Regular Expression Character Class

A Simple Examination of Character Classes

Contrasting Sed & PERL

Match Operator Example With Assignments

Remove core and a.out files

Performance Test

Program Generating Individual Files

Main Code

Subroutines Defined

Awk Regular Expression

Testing Start/Length

grab.awk translated to PERL

Cleaning up grab.pl

Globally Replace Square Braces

Generated Code from a2p

Fixes to the Code

Another Matching Approach

Best Approach Discovered

Multiple Pattern Matches with awk script

Multiple Patterns Converted to PERL

A Total Rewrite Scenario

The Final Rewrite

Subroutine definitions (Simple Approach)

Subroutine definition for checkinodes()

Subroutine for checkdiskspace()

Subroutine message()

Reference Material: