您好在以下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,ak tronic Software & Services GmbH Coplin Software Electronic Arts,Inc. Electronic Arts,Inc. In-Fusio Activision Publishing,Inc. Domark Ltd. Electronic Arts,Inc. Aspyr Media,Electronic Arts,Inc. Activision Deutschland GmbH,Activision Publishing,ak tronic Software & Services GmbH,Noviy Disk,Square Enix Co.,Ltd. Electronic Arts,Electronic Arts Ltd. Electronic Arts,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