Perl_Regular_Expressions_Part_2_m_k

Perl_Regular_Expressions_Part_2_m_k - MichaelKovalchik...

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon
Michael Kovalchik CS 265, Fall 2009
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Parenthesis group parts of expressions together “/CS265|CS270/” => “/CS(265|270)/” Groups can be nested “/Perl|Pearl/” => “/P(e(a|))rl/”
Background image of page 2
Parenthesis also serve to extract the matched  strings abcde matched with “/(abc)(de)/” will match the  string and store ‘abc’ in the variable $1 and ‘de’ in  $2
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Backreferences find earlier matches later in the  string /1 is to match the group in $1, /2 in $2, etc. “/^(\w\w\w)\s\1$/” matches when a three letter  word is duplicated with a space between the  copies
Background image of page 4
The results of a regular expression search are  stored in special variables. $` (tilde) is set to the part of the string before a match expression $’ (single quote) is set to the part of the string after a 
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 9

Perl_Regular_Expressions_Part_2_m_k - MichaelKovalchik...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online