zoukankan      html  css  js  c++  java
  • 正则表达式表常用的符号

    字符

    :  特殊字符、转义字符

    ^: 正则表达式的开始

    $: 正则表达式的结束

    *: 等于{0,},即0到多

    +: 等于{1,},即1到多

    ?: 等于{0,1},即0到1

    {n}:匹配确定的次数,n次

    {n,}:匹配大于n的次数,等于n*

    {n,m}: 匹配大于n,小于m的次数

    . :  匹配除“n”之外的任何单个字符。

     d: 匹配一个数字字符, 等价于[0-9]

    D:匹配一个非数字字符,等价于[^0-9]

    f: 匹配一个换页符

    : 匹配一个换行符

    :匹配一个回车符

    s: 匹配空白字符,包括空格、换页符等

    S: 匹配非空白字符

    :  匹配一个制表符

    v: 匹配一个垂直制表符

    w: 匹配包括下划线的任意单词字符,等价于[a-zA-Z0-9_]

    W: 匹配任何非单词字符,等价于[^a-zA-Z0-9_]

    比较常用的正则表达式判断验证:

    判断输入的是否为中文:  ^[u0391-uFFE5]+$

    判断输入的是否全为数字: [0-9]{6,}

    判断输入的是否全为字母: [a-zA-Z]{6,}

    判断输入的是否以字母为开头,有字母、数字、下划线组成: ^[a-zA-Z]w{5,15}$

  • 相关阅读:
    Data Structure and Algorithm
    Data Structure and Algorithm
    Data Structure and Algorithm
    Data Structure and Algorithm
    Data Structure and Algorithm
    Data Structure and Algorithm
    Data Structure and Algorithm
    Data Structure and Algorithm
    Data Structure and Algorithm
    Data Structure and Algorithm
  • 原文地址:https://www.cnblogs.com/xielong/p/4978115.html
Copyright © 2011-2022 走看看