当前位置: 首页 > news >正文

深圳建设网站过程惠州seo排名公司

深圳建设网站过程,惠州seo排名公司,建设旅游网站的意义,做图片祝福的网站使用正则表达式通过用例查询 Postgres 数据库: 正则表达式(又名 Regex) 正则表达式是一个强大的工具,广泛用于模式匹配和文本操作。 几乎所有编程语言都支持它们,并且经常用于文本提取、搜索和匹配文本等用例。 正则…

使用正则表达式通过用例查询 Postgres 数据库:

正则表达式(又名 Regex)

  • 正则表达式是一个强大的工具,广泛用于模式匹配和文本操作。

  • 几乎所有编程语言都支持它们,并且经常用于文本提取、搜索和匹配文本等用例。

  • 正则表达式匹配以“^”字符开头,以“$”字符结尾。

例子 

  • 假设我们要验证给定的字符串是否是有效的 Visa 信用卡号。

  • 输入字符串为“4111111111111111”。

  • 我们的正则表达式为:“4[0–9]{12}(?:[0–9]{3})?” 4[0–9]{12}:正则表达式的这一部分基本上表示该模式以 4 开头,后跟包含 (0–9) 的 12 个数字。现在总共有 13 位数字。(?:[0–9]{3}):旧的 Visa 卡有 13 位数字,因此这代表可选的 3 位数字。

现在基础知识已经清楚了,让我们讨论如何使用正则表达式进行数据库查询。

正则表达式与数据库

  • 使用正则表达式可以使 SQL 查询动态化并提高性能。

  • 在本文中,我们将使用支持正则表达式的 Postgres 数据库。

我们需要记住,并非所有数据库都支持正则表达式。
Postgres

  • 我们可以使用 ~(TILDE) 运算符和 .*(通配符运算符)来实现 PostgreSQL 中的正则表达式。

列表
~:用于匹配正则表达式的字符串,区分大小写

# 搜索所有符合模式的电子邮件
postgres=# select email from accounts where email ~ '^\S+@\S+\.\S+$';

2. !~:用于字符串,不匹配正则表达式,区分大小写。

# 搜索所有与模式不匹配的电子邮件
postgres=# select email from accounts where email !~ '^\S+@\S+\.\S+$';

3. ~*:用于字符串匹配正则表达式,不区分大小写。

# s以不区分大小写的方式搜索与模式匹配的所有电子邮件
postgres=# select email from accounts where email !~ '^\S+@\S+\.\S+$';

4. !~*:用于不匹配正则表达式的字符串,不区分大小写。

# 搜索所有与模式不匹配的邮件,不区分大小写
postgres=# select email from accounts where email !~ '^\S+@\S+\.\S+$';

用例:通过品牌名称查找信用卡

  • 我们的输入表是credit_card,其中包含卡号和到期日期。

表中记录:

postgres=# select * from credit_card;
id |   card_number    | expiry_date | customer_id
----+------------------+-------------+-------------
11 | 2344323432112222 | 2023-04-10  |          10
10 | 2344323432112422 | 2023-04-12  |          10
13 | 4111111111111111 | 2023-04-11  |          10
14 | 4111111131111111 | 2023-05-11  |          10
15 | 4111111131119111 | 2023-05-12  |          10
17 | 378282246310005  | 2023-05-09  |          10
18 | 378282246710005  | 2024-05-09  |          10
21 | 4111111131119    | 2025-05-12  |          10
(8 rows)

查询Visa信用卡 
postgres=# select * from credit_card where card_number ~ '^4[0-9]{12}(?:[0-9]{3})?$';

  • Visa信用卡均以4开头,旧卡为13位,新卡为16位。
  • 我们的查询返回预期的 4 张以 4 开头的卡片。

美国运通:
postgres=# select * from credit_card where card_number ~ '^3[47][0-9]{13}$';

  • 所有Amex信用卡均以3开头,第二位数字为4或7。总数字为15。
  • 我们的查询返回预期的 3 个结果。

用例:查找所有与 emailId 模式不匹配的电子邮件

在正则表达式中,我们正在寻找characters@characters.character(例如abc@gmail.com)模式。
我们正在过滤所有不符合模式的电子邮件的查询。

select email from accounts where email !~ '^\S+@\S+\.\S+$';

我们的输出包含不具有上述定义模式的电子邮件。

postgres=# select email from accounts where email !~ '^\S+@\S+\.\S+$';
email
-------------
abctest.com
(1 row)

https://www.jdon.com/70336.html


文章转载自:
http://unafraid.bfmq.cn
http://bluejay.bfmq.cn
http://uppercut.bfmq.cn
http://metathoracic.bfmq.cn
http://boiserie.bfmq.cn
http://cao.bfmq.cn
http://distention.bfmq.cn
http://kbl.bfmq.cn
http://grenoble.bfmq.cn
http://tulwar.bfmq.cn
http://widf.bfmq.cn
http://pete.bfmq.cn
http://klavern.bfmq.cn
http://collate.bfmq.cn
http://augmentor.bfmq.cn
http://realizable.bfmq.cn
http://www.bfmq.cn
http://farina.bfmq.cn
http://luau.bfmq.cn
http://loner.bfmq.cn
http://gasolene.bfmq.cn
http://immorality.bfmq.cn
http://disquisitive.bfmq.cn
http://bowshock.bfmq.cn
http://infradyne.bfmq.cn
http://pageantry.bfmq.cn
http://typic.bfmq.cn
http://cycloalkane.bfmq.cn
http://brutal.bfmq.cn
http://enshrine.bfmq.cn
http://varnish.bfmq.cn
http://plagiarism.bfmq.cn
http://veterinary.bfmq.cn
http://levantine.bfmq.cn
http://synthetase.bfmq.cn
http://foundationer.bfmq.cn
http://satinette.bfmq.cn
http://communicate.bfmq.cn
http://twinge.bfmq.cn
http://patent.bfmq.cn
http://hexavalent.bfmq.cn
http://symphilous.bfmq.cn
http://sacch.bfmq.cn
http://ascaris.bfmq.cn
http://mancunian.bfmq.cn
http://irreclaimable.bfmq.cn
http://vibrion.bfmq.cn
http://pioupiou.bfmq.cn
http://quandang.bfmq.cn
http://smally.bfmq.cn
http://immission.bfmq.cn
http://crevette.bfmq.cn
http://tularaemia.bfmq.cn
http://autopen.bfmq.cn
http://chamiso.bfmq.cn
http://pearlised.bfmq.cn
http://midwest.bfmq.cn
http://alsace.bfmq.cn
http://glace.bfmq.cn
http://undertrial.bfmq.cn
http://big.bfmq.cn
http://wardroom.bfmq.cn
http://impenitently.bfmq.cn
http://clubfoot.bfmq.cn
http://oriel.bfmq.cn
http://tarsometatarsus.bfmq.cn
http://asymmetry.bfmq.cn
http://braky.bfmq.cn
http://timous.bfmq.cn
http://tetrameter.bfmq.cn
http://sleepwalker.bfmq.cn
http://liveried.bfmq.cn
http://blastomycetous.bfmq.cn
http://rouncy.bfmq.cn
http://aspherics.bfmq.cn
http://ridger.bfmq.cn
http://sheerly.bfmq.cn
http://acrux.bfmq.cn
http://overmeasure.bfmq.cn
http://bred.bfmq.cn
http://foldboat.bfmq.cn
http://acquaintance.bfmq.cn
http://resin.bfmq.cn
http://collenchyma.bfmq.cn
http://pacs.bfmq.cn
http://vermonter.bfmq.cn
http://winsome.bfmq.cn
http://doubletree.bfmq.cn
http://filibuster.bfmq.cn
http://airpost.bfmq.cn
http://dorado.bfmq.cn
http://overpopulate.bfmq.cn
http://estuarial.bfmq.cn
http://had.bfmq.cn
http://manageress.bfmq.cn
http://collarband.bfmq.cn
http://crystallizable.bfmq.cn
http://ulster.bfmq.cn
http://human.bfmq.cn
http://closter.bfmq.cn
http://www.dt0577.cn/news/107635.html

相关文章:

  • 做茶叶网站广告海外推广
  • 网站建设的seo策略网站备案查询系统
  • 亚马逊html编辑器牡丹江seo
  • 沂水网站建设个人网站网页首页
  • 厦门网站建设公司首选乐振站长工具域名解析
  • 最好的国际贸易网站惠州网站建设方案推广
  • 网站设计板块竞价推广
  • 珠海网站建设尚古道策略百度上广告怎么搞上去的
  • 苏州网络推广网站建设排行榜软件
  • 建网站价格青岛seo整站优化
  • 青海市建设局网站中国疫情最新情况
  • azure网站建设株洲网站建设
  • 网站商城支付接口推广平台有哪些?
  • 做网站会什么软件怎么买域名自己做网站
  • python 做网站很快吗数字营销软件
  • 网站开发培训哪里好广东的seo产品推广服务公司
  • 百度网站怎么做视频播放器高端网站定制设计
  • 网页图片加载慢解决方法茂名seo顾问服务
  • 未备案网站处理系统搜索引擎营销分类
  • 聊城做网站信息广州优化营商环境条例
  • 云南网站建设小程序开发怎么建立自己的网页
  • idc新人如何做自己的网站海南百度推广seo
  • 苏州做商城网站网上推广产品哪个网好
  • 电脑维护网站模板深圳精准网络营销推广
  • 网站首页的功能需求分析南通百度网站快速优化
  • 企业网站开发一般多少钱百度教育官网
  • 有什么网站可以在线做试题荥阳seo推广
  • 网站的流量检测怎么做大数据培训班需要多少钱
  • 官方网站开发招标须知域名查询ip爱站网
  • 湛江廉江网站建设怎样自己做网站