您可以考虑使用正则表达式
(?i)(?:©(?:s*Copyright)?|Copyright(?:s*©)?)s*d+(?:s*-s*d+)?s*(.*?(?=W*Alls+rightss+reserved)|[^.]*(?=.)|.*)
请参阅regex演示。使用不区分大小写的修饰符
re.I。
细节
(?:©(?:s*Copyright)?|Copyright(?:s*©)?)
-要么©(?:s*Copyright)?
-©
焦炭跟随以0+空格可选子,然后Copyright
|
- 要么Copyright(?:s*©)?
-Copyright
后跟0+空格和©
char的可选子字符串
s*
-0+空格d+
-1个以上的数字(d{4}如果年份始终包含4个数字,则使用)(?:s*-s*d+)?
--
用0+空格和1+数字括起来的可选序列(d{4}如果年份始终包含4位数字,则使用)s*
-0+空格(.*?(?=W*Alls+rightss+reserved)|[^.]*(?=.)|.*)
- 捕获第1组 :以下任何一种方法:.*?(?=W*Alls+rightss+reserved)
-除换行符以外的任何0+个字符,尽可能少,最多0+个非单词字符,后跟All rights reserved
字符串[^.]*(?=.)
-.
尽可能多的0+个字符,.
不包括在内.
.*
-其余部分
Python演示:
import res = "Copyright © 2019 Apple Inc. All rights reserved.rn© 2019 Quid, Inc. All Rights Reserved.rn© 2009 Database Designs rn© 2019 Rediker Software, All Rights Reservedrn©2019 EVOSUS, INC. ALL RIGHTS RESERVEDrn© 2019 Walmart. All Rights Reserved.rn© Copyright 2003-2019 Exxon Mobil Corporation. All Rights Reserved.rnCopyright © 1978-2019 Berkshire Hathaway Inc.rn© 2019 McKesson Corporationrn© 2019 UnitedHealth Group. All rights reserved.rn© Copyright 1999 - 2019 CVS HealthrnCopyright 2019 General Motors. All Rights Reserved.rn© 2019 Ford Motor Companyrn©2019 AT&T Intellectual Property. All rights reserved.rn© 2019 GENERAL ELECTRICrnCopyright ©2019 AmerisourceBergen Corporation. All Rights Reserved.rn© 2019 Verizonrn© 2019 Fannie MaernCopyright © 2018 Jonas Construction Software Inc. All rights reserved.rnAll Comments © Copyright 2017 Kroger | The Kroger Co. All Rights Reservedrn© 2019 Express scripts Holding Company. All Rights Reserved. 1 Express Way, St. Louis, MO 63121rn© 2019 JPMorgan Chase & Co.rnCopyright © 1995 - 2018 Boeing. All Rights Reserved.rn© 2019 Bank of America Corporation. All rights reserved.rn© 1999 - 2019 Wells Fargo. All rights reserved. NMLSR ID 399801rn©2019 Cardinal Health. All rights reserved.rn© 2019 Quid, Inc All Rights Reserved."rx = r"(?:©(?:s*Copyright)?|Copyright(?:s*©)?)s*d+(?:s*-s*d+)?s*(.*?(?=W*Alls+rightss+reserved)|[^.n]*(?=.)|.*)"for m in re.findall(rx, s, re.I): print(m)
输出:
Apple IncQuid, IncDatabase Designs Rediker SoftwareEVOSUS, INCWalmartExxon Mobil CorporationBerkshire Hathaway IncMcKesson CorporationUnitedHealth GroupCVS HealthGeneral MotorsFord Motor CompanyAT&T Intellectual PropertyGENERAL ELECTRICAmerisourceBergen CorporationVerizonFannie MaeJonas Construction Software IncKroger | The Kroger CoExpress scripts Holding CompanyJPMorgan Chase & CoBoeingBank of America CorporationWells FargoCardinal HealthQuid, Inc



