Delimiters mcat musr musr musr mfile

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: -- append “##” to each line • | (verital bar) alternation: s/dog|cat/pet/g -- all dog or cat to pet • . dot: any char except new line (except ///s): m/./ non-empty string • Char-set with meta-char “-” and “^”, e.g. [A-Z] [a-z0-9] [+\-] [^0-9] • \ escape char : e.g. match for “/usr/”: $path =~ /\/usr\// 11 15 标量+数组+散列+引用 复杂与多变的Perl数据结构 • Perl数据结构可以方便地增加新的内容 • 成绩单的例子 Spring, 2010 More on RE Rule 1 Spring, 2010 • Quantifiers: * (any times, even 0), + (1 or more), ? (none or once) 例如 $line =~ s/ +/ /g; 合并相邻的空格 • Quantifiers: {n} n times, {n,} n or more, {n1, n2} n1 to n2 times • greedy (+, *) or lazy (+?, *?) 贪婪和懒惰,实例: $a = "zzzzzzzzzzzzzzzzzfaaa...
View Full Document

Ask a homework question - tutors are online