Skip to Main Content
Perl for Web Site Management
book

Perl for Web Site Management

by John Callender
October 2001
Beginner content levelBeginner
528 pages
15h 20m
English
O'Reilly Media, Inc.
Content preview from Perl for Web Site Management

Trailing Modifiers

After the last delimiter in your regular expression you can place a number of optional modifier characters that affect how the expression operates. Table 7-1 lists the more commonly used ones.

Table 7-1. Regular expression modifiers

Modifier

Description

/g

Make the match global; that is, keep looking for additional matches after the first one has been found.

/i

Match case-insensitively, such that the search pattern /walnuts/i would successfully match Walnuts and WALNUTS and so on.

/m

Treat the string as multiple lines. More specifically, let the ^ beginning-of-string anchor and the $ end-of-string anchor match at the beginning or end (respectively) of internal lines within the search string. Without the /m modifier, these anchors would match only at the beginning or end of the entire string.

/o

Compile the regular expression search pattern only once. If the search pattern contains any variables whose contents change after the first time the expression is compiled, those changes won’t be reflected in the regular expression. In effect, the /o modifier is a promise by you to Perl that any variables in the search pattern are not going to change during the time the script is running.

/s

Treat the string as a single line, even if it isn’t. Specifically, let the special character . (dot), which normally matches any character except a newline, match newline characters embedded in the string.

/x

Allow the use of regular expression ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Web Client Programming with Perl

Web Client Programming with Perl

Clinton Wong
Embedding Perl in HTML with Mason

Embedding Perl in HTML with Mason

Ken Williams, Dave Rolsky

Publisher Resources

ISBN: 1565926471Catalog PageErrata