Vsftp:/data01/mysqllog/binlog# cat a2.pl
$_="aaaa@[2]sasas";
if ($_ =~/.*?(\@\[[0-9]+\]).*/){print "\$id is $1\n"};
Vsftp:/data01/mysqllog/binlog# perl a2.pl
$id is @[2]
Vsftp:/data01/mysqllog/binlog# cat a2.pl
$_="aaaa@[23]sasas";
if ($_ =~/.*?(\@\[[0-9]+\]).*/){print "\$id is $1\n"};
Vsftp:/data01/mysqllog/binlog# perl a2.pl
$id is @[23]
d+ 匹配多个数字字符串,和 [0-9]+ 语法一样
+匹配前导模式一次或多次
[oracle@oadb test]$ cat a3.pl
$_="aaaa@[3]sasas";
if ($_ =~/.*?(\@\[[0-9]{1,3}\]).*/){print "\$id is $1\n"};
[oracle@oadb test]$ perl a3.pl
$id is @[3]
[oracle@oadb test]$ cat a3.pl
$_="aaaa@[30]sasas";
if ($_ =~/.*?(\@\[[0-9]{1,3}\]).*/){print "\$id is $1\n"};
[oracle@oadb test]$ perl a3.pl
$id is @[30]
[oracle@oadb test]$ cat a3.pl
$_="aaaa@[301]sasas";
if ($_ =~/.*?(\@\[[0-9]{1,3}\]).*/){print "\$id is $1\n"};
[oracle@oadb test]$ perl a3.pl
$id is @[301]
[oracle@oadb test]$ cat a3.pl
$_="aaaa@[3012]sasas";
if ($_ =~/.*?(\@\[[0-9]{1,3}\]).*/){print "\$id is $1\n"};
[oracle@oadb test]$ perl a3.pl
[oracle@oadb test]$
[0-9]{1,3} 匹配1到3次
{m} 匹配刚好是 m 个 的指定字符串
{m,n} 匹配在 m个 以上 n个 以下 的指定字符串
{m,} 匹配 m个 以上 的指定字符串