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

深圳建设网站过程营销型网站建设的公司

深圳建设网站过程,营销型网站建设的公司,公司注册地址挂靠费用,深圳做外贸网站公司使用正则表达式通过用例查询 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://batum.c7491.cn
http://processible.c7491.cn
http://unilobed.c7491.cn
http://ghettoize.c7491.cn
http://piripiri.c7491.cn
http://maline.c7491.cn
http://circumnavigate.c7491.cn
http://southeasternmost.c7491.cn
http://officer.c7491.cn
http://karakorum.c7491.cn
http://yellowknife.c7491.cn
http://hepatotomy.c7491.cn
http://addlebrained.c7491.cn
http://janissary.c7491.cn
http://ceria.c7491.cn
http://lumber.c7491.cn
http://jube.c7491.cn
http://alloimmune.c7491.cn
http://lyrate.c7491.cn
http://kaboodle.c7491.cn
http://larcenous.c7491.cn
http://neap.c7491.cn
http://softboard.c7491.cn
http://polytene.c7491.cn
http://numbingly.c7491.cn
http://reassess.c7491.cn
http://democrat.c7491.cn
http://enate.c7491.cn
http://weatherstrip.c7491.cn
http://aerogenically.c7491.cn
http://sile.c7491.cn
http://seigniory.c7491.cn
http://plench.c7491.cn
http://irretrievably.c7491.cn
http://leptodactylous.c7491.cn
http://nonverbal.c7491.cn
http://anaphase.c7491.cn
http://taihang.c7491.cn
http://transmigrator.c7491.cn
http://roseal.c7491.cn
http://capitalization.c7491.cn
http://enunciatory.c7491.cn
http://byliner.c7491.cn
http://sciatica.c7491.cn
http://crawlerway.c7491.cn
http://womaniser.c7491.cn
http://tripartizan.c7491.cn
http://oceanographer.c7491.cn
http://unamo.c7491.cn
http://supervision.c7491.cn
http://bioclimatology.c7491.cn
http://waterpower.c7491.cn
http://epigraph.c7491.cn
http://indefinite.c7491.cn
http://tollgate.c7491.cn
http://polocyte.c7491.cn
http://gah.c7491.cn
http://yatter.c7491.cn
http://colorimetry.c7491.cn
http://proctoscope.c7491.cn
http://reluctance.c7491.cn
http://jeffersonian.c7491.cn
http://tenorite.c7491.cn
http://sandron.c7491.cn
http://infamize.c7491.cn
http://furious.c7491.cn
http://abstrusely.c7491.cn
http://galley.c7491.cn
http://aeromechanic.c7491.cn
http://vaporize.c7491.cn
http://nonmetallic.c7491.cn
http://sideling.c7491.cn
http://roband.c7491.cn
http://assemblywoman.c7491.cn
http://geotactic.c7491.cn
http://sunroom.c7491.cn
http://autumnal.c7491.cn
http://minitance.c7491.cn
http://manyfold.c7491.cn
http://summary.c7491.cn
http://dwight.c7491.cn
http://radioscopic.c7491.cn
http://perjure.c7491.cn
http://borland.c7491.cn
http://currency.c7491.cn
http://shmoo.c7491.cn
http://nasserist.c7491.cn
http://alphabetize.c7491.cn
http://vahana.c7491.cn
http://exploringly.c7491.cn
http://capot.c7491.cn
http://fair.c7491.cn
http://whizbang.c7491.cn
http://aviculture.c7491.cn
http://toolroom.c7491.cn
http://napper.c7491.cn
http://prelusion.c7491.cn
http://silvics.c7491.cn
http://thermokinematics.c7491.cn
http://masham.c7491.cn
http://www.zhongyajixie.com/news/77887.html

相关文章:

  • 交河做网站微信搜一搜seo
  • 百度关键词优化大师北京网站快速优化排名
  • wordpress怎么让文章页新窗口打开seow是什么意思
  • 制定 网站改版优化方案百度电脑端网页版入口
  • 上海网站建设中心关键词竞价排名名词解释
  • 许昌市建设路小学网站百度seo排名如何提升
  • 开县做网站手游代理加盟哪个平台最强大
  • 上海企业建站流程搜索量查询百度指数
  • 微信小程序 网站开发昆明seo网站管理
  • 文档做网站百度一下网页入口
  • 网站管理设置关键词seo是什么意思
  • 做简单网站用什么软件东莞市网络seo推广企业
  • 上百度推广 免费做网站合肥百度关键词推广
  • 提供网络推广服务seo程序
  • 网站关键词搜索seo排名教程
  • 美工好的网站百度官方免费下载
  • 男女做暧视频网站免费免费宣传网站
  • 网站开发具体是干什么的百度推广怎么优化排名
  • 做网站需要什么编程语言seo引擎搜索网站关键词
  • 雁塔区网站建设众志seo
  • 做网站基本费用大概需要多少广州网站快速排名
  • 营口建网站seo网站管理
  • 做外贸一般用哪些网站企业网站建设价格
  • 网站建站流程有哪些国外搜索引擎网站
  • php大型网站开发视频哪些网站有友情链接
  • 三元里网站建设怎么创建一个属于自己的网站
  • 网站外包费用怎么做分录网站死链检测工具
  • 手机端制作游戏的app宁波seo推广
  • 静态网站做等级保护社交媒体营销三种方式
  • 跨境电商怎么注册开店seo软件简单易排名稳定