/[<">
首页 数据库 mysql教程 perl程序设计技巧

perl程序设计技巧

Jun 07, 2016 pm 03:23 PM
pass perl poe 技巧 程序设计

1. Why does POE pass parameters as array slices? http://poe.perl.org/?POE_FAQ/calling_convention 2. perl regular expression fast referecnces metacharacters are {}[]() ^ $ . | * + ? a metacharacter can be matched by putting a backslash befo

1. Why does POE pass parameters as array slices?
http://poe.perl.org/?POE_FAQ/calling_convention

2.  perl regular expression fast referecnces
metacharacters are

perl程序设计技巧{ } [ ] ( ) ^ $ . |  * + ? 

a metacharacter can be matched by putting a backslash before it
anchor metacharacters ^ and $ .
The anchor ^ means match at the beginning of the string and the anchor $ means match at the end of the string, or before a newline at the end of the string.

perl程序设计技巧"housekeeper" =~ /keeper/;          # matches
perl程序设计技巧
"housekeeper" =~ /^keeper/;        # doesn't match
perl程序设计技巧
"housekeeper" =~ /keeper$/;        # matches
perl程序设计技巧
"housekeeper " =~ /keeper$/;    # matchesperl程序设计技巧

A character class allows a set of possible characters, rather than just a single character, to match at a particular point in a regexp.Character classes are denoted by brackets [...], with the set of characters to be possiblly matched inside. Some examples:

perl程序设计技巧/cat/;      #matches 'cat'
perl程序设计技巧
/[bcr]at/;  #matches 'bat', 'cat', or 'rat'
perl程序设计技巧
/item[0123456789]/;   #matches 'item0' or ... or 'item9'
perl程序设计技巧
"abc" =~ /[cab]/;  #matches 'a'
perl程序设计技巧
/[yY][eE][sS]/ can be rewritten as /yes/i.

The 'i' stands for case-insensitive and is an example of a modifier of the matching operation.
The special characters for a character class are - ] / ^ $ (and the pattern delimiter, whatever it is). ] is special because it denotes the end of a character class. $ is special because it denotes a scalar variable. / is special because it is used in escape sequences.

perl程序设计技巧/[/]c]def/# matches ']def' or 'cdef'
perl程序设计技巧
   $x = 'bcr';
perl程序设计技巧   
/[$x]at/;   # matches 'bat', 'cat', or 'rat'
perl程序设计技巧
   /[/$x]at/;  # matches '$at' or 'xat'
perl程序设计技巧
   /[//$x]at/# matches '/at', 'bat, 'cat', or 'rat'

The specia character '-' acts as a range operator within a character class.

perl程序设计技巧/item[0-9]/;  # matches 'item0' or ... or 'item9'
perl程序设计技巧
/[0-9bx-z]aa/;  # matches '0aa', ..., '9aa',
perl程序设计技巧                    # 'baa', 'xaa', 'yaa', or 'zaa'

   /[0-9a-fA-F]/;  # matches a hexadecimal digit
   /[0-9a-zA-Z_]/# matches a "word" character,
perl程序设计技巧                    # like those in a Perl variable name

If '-' is the first or last character in a character class, it is treated as an ordinary character; [-ab], [ab-] and [a/-b] are all equivalent.
The special character ^ in the first position of a character class denotes a negated character class, which matches any characters but those in the brackets.

perl程序设计技巧    /[^a]at/;  # doesn't match 'aat' or 'at', but matches
perl程序设计技巧               # all other 'bat', 'cat, '0at', '%at', etc.

perl程序设计技巧
    /[^0-9]/;  # matches a non-numeric character
perl程序设计技巧
    /[a^]at/;  # matches 'aat' or '^at'; here '^' is ordinary

perl程序设计技巧/d matches a digit, not just [0-9] but also digits from non-roman scripts
perl程序设计技巧/
s matches a whitespace character, the set [/ /t/r/n/f] and others
perl程序设计技巧/
w matches a word character (alphanumeric or _), not just [0-9a-zA-Z_] but also digits and 
perl程序设计技巧     characters from non
-roman scripts
perl程序设计技巧/
D is a negated /d; it represents any other character than a digit, or [^/d]
perl程序设计技巧/
S is a negated /s; it represents any non-whitespace character [^/s]
perl程序设计技巧/
W is a negated /w; it represents any non-word character [^/w]
perl程序设计技巧The period 
'.' matches any character but "/n" (unless the modifier //s is in effect, as explained
perl程序设计技巧below)
.

perl程序设计技巧    //d/d:/d/d:/d/d/# matches a hh:mm:ss time format
perl程序设计技巧
    /[/d/s]/;         # matches any digit or whitespace character
perl程序设计技巧
    //w/W/w/;         # matches a word char, followed by a
perl程序设计技巧                      # non-word char, followed by a word char

perl程序设计技巧
    /..rt/;           # matches any two chars, followed by 'rt'
perl程序设计技巧
    /end/./;          # matches 'end.'
perl程序设计技巧
    /end[.]/;         # same thing, matches 'end.'

The alternation metacharacter | .To match dog or cat, we  form the
regexp dog|cat. As before, Perl will try to match the  regexp at the earliest possible point in the
string. At each  character position, Perl will first try to match the first  alternative, dog. If dog doesn't
match, Perl will then try the  next alternative, cat. If cat doesn't match either, then the  match fails and
Perl moves to the next position in the string.

perl程序设计技巧    "cats and dogs" =~ /cat|dog|bird/;  # matches "cat"
perl程序设计技巧
    "cats and dogs" =~ /dog|cat|bird/;  # matches "cat"

() is grouping metacharacter.

perl程序设计技巧    /(a|b)b/;    # matches 'ab' or 'bb'
perl程序设计技巧
    /(ac|b)b/;   # matches 'acb' or 'bb'
perl程序设计技巧
    /(^a|b)c/;   # matches 'ac' at start of string or 'bc' anywhere
perl程序设计技巧
    /(a|[bc])d/# matches 'ad', 'bd', or 'cd'
perl程序设计技巧
    /house(cat|)/;  # matches either 'housecat' or 'house'
perl程序设计技巧
    /house(cat(s|)|)/;  # matches either 'housecats' or 'housecat' or
perl程序设计技巧                        # 'house'.  Note groups can be nested.

perl程序设计技巧
    /(19|20|)/d/d/;  # match years 19xx, 20xx, or the Y2K problem, xx
perl程序设计技巧
    "20" =~ /(19|20|)/d/d/;  # matches the null alternative '()dd',
perl程序设计技巧                             # because '20dd' can't match

本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn

热AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover

AI Clothes Remover

用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool

Undress AI Tool

免费脱衣服图片

Clothoff.io

Clothoff.io

AI脱衣机

AI Hentai Generator

AI Hentai Generator

免费生成ai无尽的。

热门文章

R.E.P.O.能量晶体解释及其做什么(黄色晶体)
3 周前 By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.最佳图形设置
3 周前 By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.如果您听不到任何人,如何修复音频
3 周前 By 尊渡假赌尊渡假赌尊渡假赌

热工具

记事本++7.3.1

记事本++7.3.1

好用且免费的代码编辑器

SublimeText3汉化版

SublimeText3汉化版

中文版,非常好用

禅工作室 13.0.1

禅工作室 13.0.1

功能强大的PHP集成开发环境

Dreamweaver CS6

Dreamweaver CS6

视觉化网页开发工具

SublimeText3 Mac版

SublimeText3 Mac版

神级代码编辑软件(SublimeText3)

Win11小技巧分享:一招跳过微软账户登录 Win11小技巧分享:一招跳过微软账户登录 Mar 27, 2024 pm 02:57 PM

Win11小技巧分享:一招跳过微软账户登录Windows11是微软最新推出的操作系统,具有全新的设计风格和许多实用的功能。然而,对于一些用户来说,在每次启动系统时都要登录微软账户可能会感到有些烦扰。如果你是其中一员,不妨尝试一下以下的技巧,让你能够跳过微软账户登录,直接进入桌面界面。首先,我们需要在系统中创建一个本地账户,来代替微软账户登录。这样做的好处是

新手制作表格有哪些技巧 新手制作表格有哪些技巧 Mar 21, 2024 am 09:11 AM

我们经常在excel中制作和编辑表格,但是作为一个刚刚接触软件的新手来讲,如何使用excel制作表格,并没有我们使用起来那么轻松。下边,我们针对新手,也就是初学者需要掌握的表格制作的一些步骤进行一些演练,希望对需要的人有些帮助。新手表格示例样板如下图:我们看看如何来完成!1,新建excel文档,有两种方法。可以在【桌面】空白位置,点击鼠标右键-【新建】-【xls】文件。也可以【开始】-【所有程序】-【MicrosoftOffice】-【MicrosoftExcel20**】2,双击我们新建的ex

老手必备:C语言中*和&的技巧与注意事项 老手必备:C语言中*和&的技巧与注意事项 Apr 04, 2024 am 08:21 AM

C语言中,表示指针,存储其他变量的地址;&表示地址运算符,返回变量的内存地址。指针的使用技巧包括定义指针、解引用指针,需确保指针指向有效地址;地址运算符&的使用技巧包括获取变量地址,获取数组元素地址时返回数组第一元素地址。实战案例说明了使用指针和地址运算符反转字符串。

VSCode入门指南:初学者必读,快速掌握使用技巧! VSCode入门指南:初学者必读,快速掌握使用技巧! Mar 26, 2024 am 08:21 AM

VSCode(VisualStudioCode)是一款由微软开发的开源代码编辑器,具有强大的功能和丰富的插件支持,成为开发者们的首选工具之一。本文将为初学者们提供一个入门指南,帮助他们快速掌握VSCode的使用技巧。在本文中,将介绍如何安装VSCode、基本的编辑操作、快捷键、插件安装等内容,并为读者提供具体的代码示例。1.安装VSCode首先,我们需

PHP编程技巧:如何实现3秒内跳转网页 PHP编程技巧:如何实现3秒内跳转网页 Mar 24, 2024 am 09:18 AM

标题:PHP编程技巧:如何实现3秒内跳转网页在Web开发中,经常会遇到需要在一定时间内自动跳转到另一个页面的情况。本文将介绍如何使用PHP实现在3秒内实现页面跳转的编程技巧,并提供具体的代码示例。首先,实现页面跳转的基本原理是通过HTTP的响应头中的Location字段来实现。通过设置该字段可以让浏览器自动跳转到指定的页面。下面是一个简单的例子,演示如何在P

Win11技巧大揭秘:如何绕过微软账户登录 Win11技巧大揭秘:如何绕过微软账户登录 Mar 27, 2024 pm 07:57 PM

Win11技巧大揭秘:如何绕过微软账户登录近期,微软公司推出了全新的操作系统Windows11,引起了广泛关注。相比之前的版本,Windows11在界面设计、功能改进等方面做出了许多新的调整,但也引发了一些争议,其中最引人关注的一点就是强制要求用户使用微软账户登录系统。对于一些用户来说,他们可能更习惯于使用本地账户登录,而不愿意将个人信息与微软账户绑定。

暗黑like本周大乱斗:POE开新赛季!暗黑手游上线自动挂机功能 暗黑like本周大乱斗:POE开新赛季!暗黑手游上线自动挂机功能 Mar 25, 2024 pm 06:31 PM

随着《暗黑4》登陆XGP以及《流放之路》放出大量新情报。在3月的最后一周,我们又将看到一场暗黑like游戏的抢人大战。首先来聊聊已经发售一年,让人又爱又恨的《暗黑破坏神4》。此前预告了有小半年的光线追踪特性,终于要在3月26日正式加入到游戏内。新增的光线追踪效果将带来一系列视觉增强,如盔甲、水面、窗户和其他反射表面上的光线追踪反射,以及光线追踪阴影。然而,鉴于光追特效对显卡资源有较高要求,若你的电脑配置未能达到相应标准,恐难以保证游戏的流畅运行。紧接着的3月28日,《暗黑破坏神4》将正式加入Ga

Laravel表单类使用技巧:提高效率的方法 Laravel表单类使用技巧:提高效率的方法 Mar 11, 2024 pm 12:51 PM

在编写网站或应用程序时,表单是不可或缺的一部分。Laravel作为一款流行的PHP框架,提供了丰富而强大的表单类,使得表单处理变得更加简单和高效。本文将介绍一些Laravel表单类的使用技巧,帮助你提高开发效率。下面通过具体的代码示例来详细讲解。创建表单要在Laravel中创建表单,首先需要在视图中编写相应的HTML表单。在处理表单时,可以使用Laravel

See all articles