zoukankan      html  css  js  c++  java
  • 正则表达式典型案例

     
    正则表达式典型案例

    Metacharacter

    Function

    Example

    What It Matches

    ^

    Beginning-of-line anchor

    /^love/

    Matches all lines beginning with love

    $

    End-of-line anchor

    /love$/

    Matches all lines ending with love

    .

    Matches one character

    /l..e/

    Matches lines containing an l, followed by two characters, followed by an e

    *

    Matches zero or more of the preceding characters

    / *love/

    Matches lines with zero or more spaces, followed by the pattern love

    [ ]

    Matches one in the set

    /[Ll]ove/

    Matches lines containing love or Love

    [x–y]

    Matches one character within a range in the set

    /[A–Z]ove/

    Matches letters from A through Z followed by ove

    [^ ]

    Matches one character not in the set

    /[^A–Z]/

    Matches any character not in the range between A and Z

    Used to escape a metacharacter

    /love./

    Matches lines containing love, followed by a literal period; Normally the period matches one of any character

    Additional Metacharacters Supported by Many UNIX/Linux Programs That Use RE Metacharacters

    <</TT>

    Beginning-of-word anchor

    /

    Matches lines containing a word that begins with love (supported by vi and grep)

    >

    End-of-word anchor

    /love>/

    Matches lines containing a word that ends with love (supported by vi and grep)

    (..)

    Tags match characters to be used later

    /(love)able 1er/

    May use up to nine tags, starting with the first tag at the leftmost part of the pattern. For example, the pattern love is saved as tag 1, to be referenced later as 1. In this example, the search pattern consists of lovable followed by lover (supported by sed, vi, and grep)

    x{m} or x{m,} or x{m,n}

    Repetition of character x, m times, at least m times, at least m and not more than n times

    正则表达式典型案例

     
  • 相关阅读:
    线程池ThreadPoolExecutor
    常用引擎+存储过程
    在浏览器中输入www.baidu.com后执行的全过程
    win端git连接私服仓库+上传本地项目+从服务器下载文件到win
    TCP的三次握手和四次挥手+TCP和UDP的区别
    2017网易---计算糖果
    ubuntu下wireshark+scapy+tcpreply
    网易2017---数列还原
    2017网易---藏宝图
    2017网易---不要二
  • 原文地址:https://www.cnblogs.com/lixuebin/p/10814555.html
Copyright © 2011-2022 走看看