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个 以上 的指定字符串
												

perl + 匹配前导模式一次或者多次的更多相关文章

  1. Python(2.7.6) glob - 匹配指定模式的文件

    Python 标准库的 glob 模块支持查询匹配指定模式的文件或目录.这里的模式使用的并不是正则表达式,而是通过通配符来匹配的 Unix 风格的路径名扩展. 支持的通配符: 通配符 说明 *  匹配 ...

  2. 【转】fnmatch模块的使用——主要作用是文件名称的匹配,并且匹配的模式使用的unix shell风格

    [转]fnmatch模块的使用 fnmatch模块的使用 此模块的主要作用是文件名称的匹配,并且匹配的模式使用的unix shell风格.fnmatch比较简单就4个方法分别是:fnmatch,fnm ...

  3. 【原创】IBM Websphere 报错:JSPG0120E: 为 pageEncoding 属性和匹配 URI 模式的配置元素指定不同的值是非法的。

    websphere中间件,在打开一个jsp页面时报: IBM Websphere 报错:JSPG0120E: 为 pageEncoding 属性和匹配 URI 模式的配置元素指定不同的值是非法的. . ...

  4. perl 正则前导字符

    uat-prx02:/root# cat a1.pl my $str="123"; if ($str =~/(abc)*/){print "111111111\n&quo ...

  5. grep, egrep, fgrep - 打印匹配给定模式的行

    总览 SYNOPSIS grep [options] PATTERN [FILE...] grep [options] [-e PATTERN | -f FILE] [FILE...] 描述 DESC ...

  6. oc kvc的模式:匹配搜索模式(模式匹配)、装包解包

    按照一定规则使用匹配模式在目标空间进行搜索,然后执行相应操作: 运行时系统将kvc的运行机制解释为模式匹配,将值的兼容性问题解释为装包解包问题 一.模式匹配 The default implement ...

  7. 请实现一个函数用来匹配包括'.'和'*'的正则表达式。模式中的字符'.'表示任意一个字符,而'*'表示它前面的字符可以出现任意次(包含0次)。 在本题中,匹配是指字符串的所有字符匹配整个模式。例如,字符串"aaa"与模式"a.a"和"ab*ac*a"匹配,但是与"aa.a"和"ab*a"均不匹配

    // test20.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" #include<iostream> #include< ...

  8. Perl的调试模式熟悉和应用

    perl -d file.pl perl -c file.pl DB<1> hList/search source lines:               Control script ...

  9. perl匹配特殊写法

    my $name='4'; #找匹配4 for($name) { if(/^4$/) { print "success\n"; } else { print "faile ...

随机推荐

  1. Google Map JavaScript API V3 实例大全

    Google Map JavaScript API V3 实例大全 基础知识 简单的例子 地理位置 语言 位置 坐标 简单的投影 事件 简单事件 关闭事件 多次添加事件 事件属性 控制 php禁用ui ...

  2. ajaxError

    $(document).ready(function () { $('input:button').click(function() { if($('#fileName').val() == '') ...

  3. [Castle Windsor]学习依赖注入

    初次尝试使用Castle Windsor实现依赖注入DI,或者叫做控制反转IOC. 参考: https://github.com/castleproject/Windsor/blob/master/d ...

  4. [算法] get_lucky_price price

    int get_lucky_price(int price, const vector & number) 题意大概是给你一个数price,比如1000,然后有unlucky_num,有{1, ...

  5. FlatBuffers

    1 What is FlatBuffers. FlatBuffers is a serialization library for games and other memory constrained ...

  6. Array.prototype.map()详解

    今天在地铁上看到这样一个小例子: ["1","2","3"].map(parseInt); 相信很多人和我一样,觉得输出的结果是[1,2,3 ...

  7. Spring.Net AOP实例

    Spring.Net和Log4net.NUnit.NHibernate一样,也是先从Java中流行开来,然后移植到了.NET当中,形成了.NET版的Spring框架.其官方网站为:http://www ...

  8. 多线程Demo

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...

  9. C# 多线程基础

    多线程 无论您是为具有单个处理器的计算机还是为具有多个处理器的计算机进行开发,您都希望应用程序为用户提供最好的响应性能,即使应用程序当前正在完成其 他工作.要使应用程序能够快速响应用户操作,同时在用户 ...

  10. MySQL基础学习之数据库

    创建一个新的数据库 create database 数据库名称; 查看所有数据库 show databases; 删除数据库 drop database 数据库名称