Retut. <div class="noscript"><p><strong>Please note: Many features of this site require JavaScript. You appear to have JavaScript disabled, or are running a non-JavaScript capable web browser. </strong></p><p> To get the best experience, please enable JavaScript or download a modern web browser such as <a href=" Explorer 8</a>, <a href=" <a href=" or <a href=" Chrome</a>. </p></div> perlretut - Perl regular expressions tutorial This page provides a basic tutorial on understanding, creating and using regular expressions in Perl.
It serves as a complement to the reference page on regular expressions perlre. Regular expressions are an integral part of the m//, s///, qr// and split operators and so this tutorial also overlaps with Regexp Quote-Like Operators in perlop and split. Perl programming documentation. Regex Tester – RegexPal. The Perl Programming Language - www.perl.org. Perl Regular Expressions by Example. Introduction Regular expressions are very powerful tools for matching, searching, and replacing text. Unfortunately, they are also very obtuse. It does not help that most explanations of regular expressions start from the specification, which is like learning to love Friends reruns by reading a VCR manual. This page provides some simple examples for reference.
You should know a little programming and how to run basic perl scripts before reading this article. Section 1: Basic matching and substitution Declare a local variable called $mystring. my $mystring; Assign a value (string literal) to the variable. $mystring = "Hello world! " Does the string contains the word "World"? If($mystring =~ m/World/) { print "Yes"; } No, it doesn't. Does the string contains the word "World", ignoring case? If($mystring =~ m/World/i) { print "Yes"; } Yes, it does. I want "Hello world! " $mystring =~ s/world/mom/; print $mystring; Prints "Hello mom!
". Now change "Hello mom! " Okay, ignoring case, change "Hello mom! " *?