9.7. Pattern Matching
9.7. Pattern Matching
9.7. 模式匹配
There are three separate approaches to pattern matching provided by PostgreSQL: the traditional SQL LIKE operator, the more recent SIMILAR TO operator (added in SQL:1999), and POSIX-style regular expressions. Aside from the basic “does this string match this pattern?” operators, functions are available to extract or replace matching substrings and to split a string at matching locations.
PostgreSQL提供了三种单独的模式匹配方法:传统的SQL LIKE运算符,SIMILAR TO运算符(在SQL:1999中添加)和POSIX样式的正则表达式。除了基本的“此字符串是否匹配此模式?”运算符,函数可用于提取或替换匹配的子字符串并在匹配的位置拆分字符串。
Tip
小贴士
If you have pattern matching needs that go beyond this, consider writing a user-defined function in Perl or Tcl.
如果有超出此范围的模式匹配需求,可以考虑使用Perl或Tcl编写用户自定义的函数。
Caution
注意
While most regular-expression searches can be executed very quickly, regular expressions can be contrived that take arbitrary amounts of time and memory to process. Be wary of accepting regular-expression search patterns from hostile sources. If you must do so, it is advisable to impose a statement timeout.
尽管大多数正则表达式搜索可以非常快速地执行,但却也可以构造能够耗费任意时间及内存去执行的正则表达式。因此从未知来源接受正则表达式的时候,一定要谨慎。如果必须这样做,则建议强制限制语句超时。
Searches using SIMILAR TO patterns have the same security hazards, since SIMILAR TO provides many of the same capabilities as POSIX-style regular expressions.
使用SIMILAR TO模式进行的搜索具有相同的安全隐患,因为SIMILAR TO提供了许多与POSIX样式正则表达式相同的功能。
LIKE searches, being much simpler than the other two options, are safer to use with possibly-hostile pattern sources.
与其他两个选项相比,LIKE搜索要简单得多,它与可能有害的模式源一起使用安全性会高一些。
9.7. Pattern Matching相关推荐
- CodeForces - 1476E Pattern Matching(字典树+拓扑)
题目链接:点击查看 题目大意:给出 nnn 个模式串和 mmm 个匹配串,题目要求输出一种模式串的排列方式,使得 mmm 个模式串从头开始匹配的话,可以匹配到相应的模式串 模式串的长度不超过 444, ...
- C#9.0 终于来了,带你一起解读 nint 和 Pattern matching 两大新特性玩法
一:背景 1. 讲故事 上一篇C#9.0 终于来了,您还学的动吗? 带上VS一起解读吧!跟大家聊到了Target-typed new 和 Lambda discard parameters,看博客园和 ...
- E. Pattern Matching(题意理解+拓扑排序)
E. Pattern Matching 首先p[mtj]p[mt_j]p[mtj]必须能够匹配所给字符sjs_jsj,然后把所有能够匹配的sjs_jsj的其他模板串也找出来,这些必须放在p[mt ...
- PEP 634 – Structural Pattern Matching: Specification
PEP 634 – Structural Pattern Matching: Specification PEP 634 – 结构化模式匹配:规范 PEP: 634 Title: Structural ...
- 论文翻译——Multi-Constrained Graph Pattern Matching in Large-Scale Contextual Social Graphs
文章目录 Abstract 附加 Introduction Background 附加 Problem 附加 Contribuitions 附加 Related Work (1) 附加 (2) 附加 ...
- Python 3.10 的新功能:模式匹配 Pattern Matching
简介 2021 年 3 月 2 日的时候,Guido 发推说 3.10.0a6 出来了,文档也已经有了,4 月 5 日会释出 a7,5 月 3 日出 b1. 推文中还特别提到「With Pattern ...
- 模式匹配Pattern Matching
目录 1.模式匹配(pattern matching)的概念 2. 制造模式匹配的测试串 3. 模式匹配蛮力算法(Brute-Force,也成Naive朴素算法) 3.1 Version 1 3.2 ...
- 面试题 16.18. Pattern Matching LCCI
Title 你有两个字符串,即pattern和value. pattern字符串由字母"a"和"b"组成,用于描述字符串中的模式.例如,字符串"cat ...
- 函数式编程之-模式匹配(Pattern matching)
编者:C# 7.0也加入了模式匹配,来源于F#. 模式匹配在F#是非常普遍的,用来对某个值进行分支匹配或流程控制. 模式匹配的基本用法 模式匹配通过match...with表达式来完成,一个完整的模式 ...
最新文章
- 【Linux】一步一步学Linux——mktemp命令(263)
- 正则表达式里转义字符_五分钟搞定正则表达式,如果没搞定,再加两分钟
- ECharts 饼图 legend 样式修改
- js 根据掩码位计算可用ip地址_变长子网掩码:轻松分配IP地址(下)
- 深度剖析Kubernetes API Server三部曲 - part 3
- 直播预告丨MySQL中的索引探究
- 真正的创业是什么感觉?
- 学校中有老师和学生两类人,而在职研究生既是老师又是学生,对学生的管理和对教师的管理在他们身上都有体现。...
- Xcode真机调试中“There was an internal API error“错误解决方法
- (1)python基础语法
- ASP.NET学生管理系统(.NET毕业设计)
- STM32F4 GPIO模式及工作原理详解
- FFMpeg-6、Libavdevice+SDL捕获显示摄像头、录屏
- ActionBar隐藏app图标
- linux网页打开慢的解决方法,解决Ubuntu浏览网页速度慢的问题
- c语言数码管显示小数点,8位数码管显示正整数和小数及解决鬼影问题
- 解决Unknown column XXX in ‘field list‘问题
- Nodejs 开发最佳实践
- 解决iphone4无法格式化号码的问题
- 软件设计师_计算机网络——IP地址和子网掩码