![](/img/trans.png)
[英]Extract text between commas and quotes, ignoring escaped characters in perl
[英]get text from file between quotes and commas
我有这样的大文件行-它的一行:
('serve1','type',0,'zone.x.target',1,'ab23423u',0,),('actual','type8',0,'code.is.avail',1,'srerwerwer');
我只想提取('和','之间的文本,因此在该示例中,正确的输出必须为
服务1
实际
如果您的正则表达式引擎支持后向:
(?<=\(')[^']*
如果有gnu-grep可用: grep -Po "\\('\\K[^']*" file
kent$ echo "('serve1','type',0,'zone.x.target',1,'ab23423u',0,),('actual','type8',0,'code.is.avail',1,'srerwerwer');"|grep -Po "\('\K[^']*"
serve1
actual
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.