正则表达式 – 如何使用sed搜索和替换,而不包括一组字符?

您好在以下sed命令中我需要在第二组括号中不接受以下单词组:Inc The Ltd LLC

它会破坏list.txt中的以下数据,使每个公司名称都在一行上,公司名称在逗号后面,但有时“Inc”,“Ltd”,“LLC”和“The”跟随公司.

这是非常先进的正则表达式,我似乎无法得到.

sed -re 's/([a-zA-Z.]), (Need code here)/\1\n\2/g' list.txt

list.txt包含以下数据:

Electronic Arts, Inc., Electronic Arts Ltd.
Activision Publishing, Inc., ak tronic Software & Services GmbH
coplin Software
Electronic Arts, Inc.
Electronic Arts, Inc.
In-Fusio
Activision Publishing, Inc.
Domark Ltd.
Electronic Arts, Inc.
Electronic Arts, Inc.
Aspyr Media, Inc., Electronic Arts, Inc.
Activision Deutschland GmbH, Activision Publishing, Inc., ak tronic Software & Services GmbH, Noviy disk, Square Enix Co., Ltd.
Electronic Arts, Inc.
Electronic Arts, Inc., Electronic Arts Ltd.
Electronic Arts, Inc.
Electronic Arts, Inc.
Electronic Arts, Inc., Electronic Arts Square, K.K., MGM Interactive
Electronic Arts Ltd.

预期输出(注意逗号):

GarageGames, Inc.
The Avalon Hill Game Company
Microforum International, The
Telenet Japan Co., Ltd.
glu Mobile, Inc.
Warner bros. Digital distribution
Atari, Inc.

解决方法:

perl -pe 's/([^,]), (?!Inc|LLC|The|Ltd)/\1\n/g' list.txt

相关文章

用的openwrt路由器,家里宽带申请了动态公网ip,为了方便把2...
#!/bin/bashcommand1&command2&wait从Shell脚本并行...
1.先查出MAMP下面集成的PHP版本cd/Applications/MAMP/bin/ph...
1、先输入locale-a,查看一下现在已安装的语言2、若不存在如...
BashPerlTclsyntaxdiff1.进制数表示Languagebinaryoctalhexa...
正常安装了k8s后,使用kubect工具后接的命令不能直接tab补全...