XML technologies / Regular expressions / Perl / The match operator

(Excerpt from "Regular expressions" by Jeffrey E. F. Friedl)

Simple pattern matching

$text =~ m/Regex/Modifikatoren

is the core of regex operators in Perl. In Perl, pattern matching is an operator taking two operands, the input string and a regex, and returning a value.

Exactly how matching works and what kind of value it returns depend on context (see context) and other factors. The match operator is very flexible: it can simply apply a regex, extract data from a string or, together with other match operators, work through a string piece by piece to parse it. Such flexibility also requires learning how to use it. Important points are:

The general form of pattern matching is:

SuchtextOperand =~ RegexOperand

Several abbreviated forms exist, and no component appears in every form. This section introduces all of them.

  

  

 

 

 

German edition copyright © 2008 by O’Reilly Verlag GmbH & Co. KG
You may print the online version for private use.
Otherwise, this chapter from "Reguläre Ausdrücke" is subject to the same terms as the bound edition: the work and all its parts are protected by copyright. All rights reserved, including reproduction, translation, microfilming, storage and processing in electronic systems.

O’Reilly Verlag GmbH & Co. KG, Balthasarstr. 81, 50670 Köln

back to top