- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
一段时间以来,我一直在尝试寻找一个强大的正则表达式来从版权声明中提取公司名称(并且对正则表达式了解不多)。
在这个问题中:Regex to match company names from copyright statements under several conditions
我得到了正则表达式:
(?i)(?:©(?:\s*Copyright)?|Copyright(?:\s*©)?)\s*\d+(?:\s*-\s*\d+)?\s*(.*?(?=\W*All\s+rights\s+reserved)|[^.]*(?=\.)|.*)
但是当我尝试更多示例时,我发现这还不够。我想更改它,使其也符合以下条件,同时仍然适用于所有以前的情况:
例子:
602-226-2389 ©2019 Endurance International Group.
Copyright 1999 — 2019 © Iflexion. All rights reserved.
例子:
ISO 9001:2008, ISO/ IEC 27001:2005 © Mobikasa 2019
例子:
© 2019 Copyright arcadia.io.
2018 © Power Tools LLC
例子:
Copyright 2019 ComputerEase Construction Software | 1-800-544-2530
最佳答案
你可以使用
(?i)(?:©(?:\s*(?:\d{4}(?:\s*[-—–]\s*\d{4})?)?\s*Copyright)?|Copyright(?:\s*(?:\d{4}(?:\s*[-—–]\s*\d{4})?)?\s*©)?)(?:\s*\d{4}(?:\s*[-—–]\s*\d{4})?)?\s*(.*?(?=\s*[.|]|\W*All\s+rights\s+reserved)|.*\b)
参见 regex demo
Python代码:
import re
s = "Copyright © 2019 Apple Inc. All rights reserved.\r\n© 2019 Quid, Inc. All Rights Reserved.\r\n© 2009 Database Designs \r\n© 2019 Rediker Software, All Rights Reserved\r\n©2019 EVOSUS, INC. ALL RIGHTS RESERVED\r\n© 2019 Walmart. All Rights Reserved.\r\n© Copyright 2003-2019 Exxon Mobil Corporation. All Rights Reserved.\r\nCopyright © 1978-2019 Berkshire Hathaway Inc.\r\n© 2019 McKesson Corporation\r\n© 2019 UnitedHealth Group. All rights reserved.\r\n© Copyright 1999 - 2019 CVS Health\r\nCopyright 2019 General Motors. All Rights Reserved.\r\n© 2019 Ford Motor Company\r\n©2019 AT&T Intellectual Property. All rights reserved.\r\n© 2019 GENERAL ELECTRIC\r\nCopyright ©2019 AmerisourceBergen Corporation. All Rights Reserved.\r\n© 2019 Verizon\r\n© 2019 Fannie Mae\r\nCopyright © 2018 Jonas Construction Software Inc. All rights reserved.\r\nAll Comments © Copyright 2017 Kroger | The Kroger Co. All Rights Reserved\r\n© 2019 Express Scripts Holding Company. All Rights Reserved. 1 Express Way, St. Louis, MO 63121\r\n© 2019 JPMorgan Chase & Co.\r\nCopyright © 1995 - 2018 Boeing. All Rights Reserved.\r\n© 2019 Bank of America Corporation. All rights reserved.\r\n© 1999 - 2019 Wells Fargo. All rights reserved. NMLSR ID 399801\r\n©2019 Cardinal Health. All rights reserved.\r\n© 2019 Quid, Inc All Rights Reserved.\r\n602-226-2389 ©2019 Endurance International Group.\r\nCopyright 1999 — 2019 © Iflexion. All rights reserved.\r\nISO 9001:2008, ISO/ IEC 27001:2005 © Mobikasa 2019\r\n© 2019 Copyright arcadia.io.\r\n2018 © Power Tools LLC\r\nCopyright 2019 ComputerEase Construction Software | 1-800-544-2530\r\n© 2019 3M. 3M Health Information Systems Privacy Policy"
rx = r'''(?xi)
(?:© # Start of a group: © symbol
(?:\s* # Start of optional group: 0+ whitespaces
(?:\d{4} # Start of optional group: 4 digits
(?:\s*[-—–]\s*\d{4})? # 0+ spaces, dashes, spaces, 4 digits
)? # End of group
\s*Copyright # Spaces and Copyright
)? # End of group
| # OR
Copyright
(?:\s* # Start of optional group: 0+ whitespaces
(?:\d{4} # Start of optional group: 4 digits
(?:\s*[-—–]\s*\d{4})? # 0+ spaces, dashes, spaces, 4 digits
)?\s*© # End of group, 0+ spaces, ©
)? # End of group
) # End of group
(?:\s*\d{4}(?:\s*[-—–]\s*\d{4})?)? # Optional group, 9999 optionally followed with dash enclosed with whitespaces and then 9999
\s* # 0+ whitespaces
( # Start of a capturing group:
.*? # any 0+ chars other than linebreak chars, as few as possible, up to...
(?=\s*[.|]| # 0+ spaces and then | or ., or
\W*All\s+rights\s+reserved) # All rights reserved with any 0+ non-word chars before it
| # or
.*\b # any 0+ chars other than linebreak chars, as many as possible
)'''
for m in re.findall(rx, s):
print(m)
参见 Python demo .输出:
Apple Inc
Quid, Inc
Database Designs
Rediker Software
EVOSUS, INC
Walmart
Exxon Mobil Corporation
Berkshire Hathaway Inc
McKesson Corporation
UnitedHealth Group
CVS Health
General Motors
Ford Motor Company
AT&T Intellectual Property
GENERAL ELECTRIC
AmerisourceBergen Corporation
Verizon
Fannie Mae
Jonas Construction Software Inc
Kroger
Express Scripts Holding Company
JPMorgan Chase & Co
Boeing
Bank of America Corporation
Wells Fargo
Cardinal Health
Quid, Inc
Endurance International Group
Iflexion
Mobikasa 2019
arcadia
Power Tools LLC
ComputerEase Construction Software
3M
关于python - 正则表达式在更多条件下匹配版权声明中的公司名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55288521/
有谁知道是否可以在 Azure Authenticator 应用程序中向帐户添加自定义图像?对于我们的所有帐户,它始终显示上传到 AAD 的用户照片或通用徽章图像 我们希望将我们公司的图像添加到帐户中
我正在将分离的实体传递给 persist: model。公司当我使用@OneToMany映射时。我尝试了不同的方法但结果相同。我添加了 @OneToMany 和 CascadeTypes Persis
关闭。这个问题是opinion-based .它目前不接受答案。 想要改进这个问题? 更新问题,以便 editing this post 可以用事实和引用来回答它. 关闭 9 年前。 Improve
我正在尝试为多家公司生产的产品、他们的配件以及产品和配件与客户账户的关联设计一个数据库。 您将如何设计这样的数据库来实现此功能? 商业规则 一个产品总是与一个公司相关联,一个公司可以有很多产品。 除产
这更像是一个普遍问题,即哪个方向对公司来说是更好的投资。 我们公司的核心业务应用程序是用 Visual FoxPro 编写的,已有大约 9 年以上的历史。该数据库庞大,超过 15 GB,核心逻辑复杂,
我刚刚尝试创建一个安装在 Android 上的应用程序列表。我想这样做,以便在备份并将手机重置为出厂设置之前获得已安装的应用程序列表。 到目前为止一切顺利,我有以下信息: 包名 友好的名字 版本号/代
我有一个包含公司及其产品的数据库,我想要每个公司拥有单独的产品 ID 序列。 我知道postgresql做不到这个,唯一的办法就是每个公司都有一个单独的序列,但这很麻烦。 我想到了一个解决方案,用一个
我正在使用带有 m2e 的 Eclipse Indigo(它连接到 Maven 3.0.3 的外部二进制文件)。 现在,我的应用程序的预期结构如下: Company-parent --Project-
我有一个关于 Lucene/Solr 的问题。 我正在尝试解决一般(公司)名称匹配问题。 让我举一个过于简单的例子: 我们有两个(可能很大)名称列表,即 list_A 和 list_B。我们想找到两个
已结束。此问题正在寻求书籍、工具、软件库等的推荐。它不满足Stack Overflow guidelines 。目前不接受答案。 我们不允许提出寻求书籍、工具、软件库等推荐的问题。您可以编辑问题,以便
我正在开发一些通过企业计划分发到公司 iPad 上的应用程序(因此我/公司可以完全控制它们)。在公司拥有的设备的上下文中,什么是“正确的”(如果有的话)识别运行应用程序的设备的方法? 按照此处的建议创
我的 SQL 数据库中有两个表: 公司: ID(自增) 姓名 地址 ... 员工: ID(自增) 公司编号 internal_id 姓名 姓氏 问题是我想要一个与他们所属的公司相关的员工 ID (in
在为用户获取公司列表时,它会为没有 Logo 的公司抛出 500 错误代码。 使用 logo-url 参数查询: curl "https://api.linkedin.com/v1/companies
如何在不访问的情况下获取 Liferay 中的全局(公司)组 ID ThemeDisplay ? P.S.:与 ThemeDisplay很简单:themeDisplay.getCompanyGroup
有人可以帮助我以最佳方式在流畅的 nHibernate 中映射以下情况吗? Address 类用于 Client 和 Company。如何在 SQL 中最有效地存储它?映射应该是什么样的?我已经考虑过
我是数据库设计新手,请给我一些建议。 1 When should I use a composite index? im not sure what does index does, but i do
我有一个为 A 公司完成的 Grails 应用程序。现在需要对 B 公司进行一些更改。 我不想复制整个项目,因为它会在以后产生问题(代码重复、硬管理、修复双方的错误等) 相反,我希望有一些公司特定的代
我正在考虑使用一个 image 表来存储任何其他独立表的图像,例如 user、product 等... (当然,独立表的任何单个实例(例如作为用户的John Smith,以及作为产品的笔记本电脑) )
我正在尝试为 Vuzix M300 智能眼镜开发应用程序。我已经通过 Android SDK Manager 安装了 Vuzix SDK。我已按照 Vuzix 文档中提到的所有步骤进行操作。我还将编译
我正准备将我的第一个 iOS 提交到应用商店。我目前正在权衡为我的开发者帐户创建 LLC 以提交到应用商店的利弊,而不是仅作为个人提交。 在以前的论坛帖子中,Apple 过去似乎需要更长的时间(数月)
我是一名优秀的程序员,十分优秀!