$1 在 Perl 中是什么意思? [英] What does $1 mean in Perl?

查看:55
本文介绍了$1 在 Perl 中是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

$1 在 Perl 中是什么意思?此外,$2 是什么意思?有多少个 $number 变量?

What does $1 mean in Perl? Further, what does $2 mean? How many $number variables are there?

推荐答案

$number 变量包含与 捕获组 ( ... ) 在您最后一个正则表达式匹配的模式中,如果匹配成功.

The $number variables contain the parts of the string that matched the capture groups ( ... ) in the pattern for your last regex match if the match was successful.

例如,采用以下字符串:

For example, take the following string:

$text = "the quick brown fox jumps over the lazy dog.";

声明后

$text =~ m/ (b.+?) /;

$1 等于文本brown".

这篇关于$1 在 Perl 中是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆