Perl Pattern Matching

Simple Pattern matching in Perl





<b>abc</b> - abc (that exact character sequence, but anywhere in the string)
<b>^abc</b> - abc at the beginning of the string
<b>abc$</b> - abc at the end of the string
<b>a|b</b> -either of a and b
<b>^abc|abc$</b> - the string abc at the beginning or at the end of the string
<b>ab{2,4}c</b> - an a followed by two, three or four b followed by a c
<b>ab{2,}c</b> - an a followed by at least two b followed by a c
<b>ab*c</b> - an a followed by any number (zero or more) of b followed by a c
<b>ab+c</b> - an a followed by one or more b followed by a c
<b>ab?c</b> - an a followed by an optional b followed by a c; that is, either abc or ac
<b>a.c</b> - an a followed by any single character (not newline) followed by a c
<b>[abc]</b> - any one of a, b and c
<b>[Aa]bc</b> - either of Abc and abc
<b>[abc]+</b> - any (nonempty) string of a, b and c (such as a, abba, acbabcacaa)
<b>[^abc]+</b> - any (nonempty) string which does not contain any of a, b and c (such as defg)




Related Topic Basic Linux Commands
Useful Regular Expression Regex Syntax and Examples the Web Developer Need to Know
What are all Perl Internal Data Types
How to Create Scalar Values Manipulation in Perl Scripting
What is Scalar Values Manipulation in Perl Scripting
Perl  

nScraps.com 2011   Privacy Policy  Terms of Service  Feedback