In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces several forms of Perl regular expression, which is very detailed and has certain reference value. Friends who are interested must read it!
Perl regular expression
Three forms of Perl regular expressions
First of all, we should know that there are three forms of Perl regular expressions in Perl programs, which are:
◆ match: M _ jump / (can also be abbreviated to / /, omitting m)
◆ replacement: Splash /
◆ conversion: tr///
These three forms are generally used with = ~ or! ~ (where "= ~" is a match, read as does in the whole sentence, and "! ~" is read as doesn't in the whole sentence), and scalar variables to be processed on the left. Without this variable and the = ~! ~ operator, the contents of the $_ variable are processed by default. Examples are as follows:
$str= "IlovePerl"
$str=~m/Perl/;# means that if the string "Perl" is found in $str, it returns "1" otherwise it returns "0".
$str=~s/Perl/BASH/;# means to replace the "Perl" string in the variable $str with "BASH", returning "1" if this replacement occurs, and "0" otherwise.
$stringed letters tracker, Amurz str, Amurz, etc. # means to convert all uppercase letters in the variable $string to lowercase letters, and return "0" if the conversion occurs, or "1" otherwise.
There are also:
Foreach (@ array) {sqqr _ b _;} # where each loop takes an element from the @ array array and stores it in the $_ variable, and replaces the $_.
The sentence while () {printif (m/error/);} # is slightly more complicated, he will print all the lines in the FILE file that contain the error string.
If () appears in Perl's Perl regular expression, the pattern in () is automatically assigned to the system $1 by the Perl interpreter after matching or replacing. Take a look at the following example:
$string= "Iloveperl"
These are all the contents of the article "there are several forms of Perl regular expressions". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.