




免费预览已结束,剩余9页可下载查看
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
正则表达式( regex) 是定义复杂查询的一个强有力的工具。这里是一个简单的资料,它忽略了一些详细的信息。正则表达式定义了一个字符串的规则。最简单的正则表达式不包含任何保留字。例如,正则表达式hello 只和字符串 “ hello ” 匹配。一般的正则表达式使用了某些特殊的结构,所以它能匹配更多的字符串。例如,正则表达式hello|word既能匹配字符串“ hello ” 也能匹配字符串“ word ” 。举一个更复杂一点的例子,正则表达式ban*s可以匹配字符串“ bananas ” 、“baaaaas ” 、“ bs” 以及其他任何以b 开头以 s 结尾的字符串,中间可以包括任意个a 和任意个n 的组合。一个正则表达式中的可以使用以下保留字所匹配的字符串以后面的字符串开头mysql select fonfo regexp fo$; - 0(表示不匹配)mysql select fofo regexp fo; - 1(表示匹配)$所匹配的字符串以前面的字符串结尾mysql select fono regexp fono$; - 1(表示匹配)精品资料mysql select fono regexp fo$; - 0(表示不匹配).匹配任何字符(包括新行)mysql select fofo regexp f.*; - 1(表示匹配)mysql select fonfo regexp f.*; - 1(表示匹配)a*匹配任意多个a(包括空串 )mysql select ban regexp ba*n; - 1(表示匹配)mysql select baaan regexp ba*n; - 1(表示匹配)mysql select bn regexp ba*n; - 1(表示匹配)a+匹配任意多个a(不包括空串)mysql select ban regexp ba+n; - 1(表示匹配)mysql select bn regexp ba+n; - 0(表示不匹配)a?匹配一个或零个amysql select bn regexp ba?n; - 1(表示匹配)mysql select ban regexp ba?n; - 1(表示匹配)mysql select baan regexp ba?n; - 0(表示不匹配)de|abc匹配 de 或 abcmysql select pi regexp pi|apa; - 1(表示匹配)mysql select axe regexp pi|apa; - 0(表示不匹配)mysql select apa regexp pi|apa; - 1(表示匹配)mysql select apa regexp (pi|apa)$; - 1(表示匹配)mysql select pi regexp (pi|apa)$; - 1(表示匹配)mysql select pix regexp (pi|apa)$; - 0(表示不匹配)(abc)*匹配任意多个abc (包括空串 )mysql select pi regexp (pi)*$; - 1(表示匹配)mysql select pip regexp (pi)*$; - 0(表示不匹配)mysql select pipi regexp (pi)*$; - 1(表示匹配)12,3这是一个更全面的方法,它可以实现前面好几种保留字的功能a*可以写成a0,a+可以写成a1,a?可以写成a0,1在 内只有一个整型参数i,表示字符只能出现i 次;在 内有一个整型参数i,后面跟一个“,” ,表示字符可以出现i 次或 i 次以上; 在内只有一个整型参数i,后面跟一个 “,” , 再跟一个整型参数j,表示字符只能出现i 次以上, j 次以下(包括i 次和 j 次)。其中的整型参数必须大于等于0,小于等于 re_dup_max(默认是255 )。如果有两个参数,第二个必须大于等于第一个a-dx匹配 “ a”、“ b” 、“ c” 、“ d” 或“ x ”a-dx匹配除 “ a” 、“ b” 、“ c” 、“ d”、“ x” 以外的任何字符。“ ” 、“ ” 必须成对使用mysql select axbc regexp a-dxyz; - 1(表示匹配)mysql select axbc regexp a-dxyz$; - 0(表示不匹配)mysql select axbc regexp a-dxyz+$; - 1(表示匹配)mysql select axbc regexp a-dxyz+$; - 0(表示不匹配)mysql select gheis regexp a-dxyz+$; - 1(表示匹配)mysql select gheisa regexp a-dxyz+$; - 0(表示不匹配)-.characters.表示比较元素的顺序。在括号内的字符顺序是唯一的。但是括号中可以包含通配符, 所以他能匹配更多的字符。举例来说:正则表达式.ch.*c匹配 chchcc的前五个字符。=character_class=表示相等的类,可以代替类中其他相等的元素,包括它自己。例如,如果o 和(+) 是一个相等的类的成员,那么=o= 、=(+)= 和o(+) 是完全等价的。:character_class:在括号里面,在: 和:中间是字符类的名字,可以代表属于这个类的所有字符。字符类的名字有: alnum 、digit 、punct 、alpha 、graph 、space 、blank 、lower 、upper 、cntrl 、print 和 xdigitmysql select justalnums regexp :alnum:+; - 1(表示匹配)mysql select ! regexp :alnum:+; - 0(表示不匹配):分别匹配一个单词开头和结尾的空的字符串,这个单词开头和结尾都不是包含在alnum 中的字符也不能是下划线。mysql select a word a regexp :; - 1(表示匹配)mysql select a xword a regexp :; - 0(表示不匹配)mysql select weeknights regexp (wee|week)(knights|nights)$; - 1(表示匹配)description of mysql regular expression syntaxa regular expression (regex) is a powerful way of specifying a complex search.mysql uses regular henry spencers inplementation of regular expressions. and that is aimed to conform to posix 1003.2.mysql uses the extended version.this is a simplistic reference that skips the details. to get more exact information, see henry spencers regex(7) manual page that is included in the source distribution. see section c contributors to mysql.a regular expression describes a set of strings. the simplest regexp is one that has no special characters in it. for example, the regexp hello matches hello and nothing else.nontrivial regular expressions use certain special constructs so that they can match more than one string. for example, the regexp hello|word matches either the string hello or the string word.as a more complex example, the regexp ban*s matches any of the strings bananas, baaaaas, bs and any other string starting with a b, ending with an s, and containing any number of a or n characters in between.a regular expression may use any of the following special characters/constructs:match the beginning of a string.mysql select fonfo regexp fo$;- 0mysql select fofo regexp fo;- 1$match the end of a string.mysql select fono regexp fono$;- 1mysql select fono regexp fo$;- 0.match any character (including newline).mysql select fofo regexp f.*;- 1mysql select fonfo regexp f.*;- 1a*match any sequence of zero or more a characters.mysql select ban regexp ba*n;- 1mysql select baaan regexp ba*n;mysql select bn regexp ba*n;- 1- 1a+match any sequence of one or more a characters.mysql select ban regexp ba+n;- 1a?mysql select bn regexp ba+n;- 0match either zero or one a character.mysql select bn regexp ba?n;- 1mysql select ban regexp ba?n;- 1de|abcmysql select baan regexp ba?n;- 0match either of the sequences de or abc.mysql select pi regexp pi|apa;- 1mysql select axe regexp pi|apa;- 0mysql select apa regexp pi|apa;- 1mysql select apa regexp (pi|apa)$;- 1mysql select pi regexp (pi|apa)$;- 1mysql select pix regexp (pi|apa)$;- 0(abc)*match zero or more instances of the sequence abc. mysql select pi regexp (pi)*$;- 1mysql select pip regexp (pi)*$;- 0mysql select pipi regexp (pi)*$;- 112,3the is a more general way of writing regexps that match many occurrences of the previous atom.a*can be written as a0,. a+can be written as a1,.a?can be written as a0,1.to be more precise, an atom followed by a bound containing one integer i and no comma matches a sequence of exactly i matches of the atom. an atom followed by a bound containing one integer i and acomma matches a sequence of i or more matches of the atom. an atom followed by a bound containing two integers i and j matches a sequence of i through j (inclusive) matches of the atom. both arguments must 0 = value select axbc regexp a-dxyz;- 1mysql select axbc regexp a-dxyz$;- 0mysql select axbc regexp a-dxyz+$;- 1mysql select axbc regexp a-dxyz+$;- 0mysql select gheis regexp a-dxyz+$;- 1mysql select gheisa regexp a-dxyz+$;- 0.characters.alnumdigitpunctalphagraphspaceblankloweruppercntrlprintxdigitthe sequence of characters of that collating element. the sequence is a single element of the bracket expressions list. a bracket expression containing a multi-character collating element can thus match more than one character, e.g., if the collating sequence includes a ch collating element, then the regular expression .ch.*c matches the first five characters of chchcc.=character_class=an equivalence class, standing for the sequences of characters of all collating elements equivalent to that one, including itself. for example, if o and (+) are the members of an equivalence class, then =o=, =(+)=, and o(+) are all synonymous. an equivalence class may not be an endpoint of a range.:character_class:within a bracket expression, the name of a character class enclosed in : and : stands for the list of all characters belonging
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 二零二五年户外广告设施保洁劳务分包合同书范本
- 二零二五年户外广告牌立体造型设计与施工合同
- 2025版监管金融监管总局三连发金融业务合规审查合同
- 二零二五年婚礼纪婚车租赁与婚庆策划专属合同
- 二零二五年养老产业担保合同范本解析
- 2025版新能源项目采购合同范本
- 2025版建筑行业借款合同范本
- 2025版餐饮业冷链物流运输合作协议书
- 二零二五年度城市核心区精装公寓租赁合同模板
- 2025版建筑劳务分包合同标准文本
- 2025年官方兽医牧运通考试题库附参考答案详解(考试直接用)
- 2025年兵团辅警考试题库
- 主机厂车辆采购合同范本
- 2025年湖南省直机关遴选公务员考试笔试试卷【附答案】
- 家电广告效果评估报告
- 锐澳RIO抖音dp运营方案
- 2025年交通安全法规题库及答案
- 输电线路路经复测安全、技术交底
- lpr利率管理办法
- 课堂有效教学课件
- 规范诊疗培训课件
评论
0/150
提交评论