从特定字段中删除引号 – 引号之间的整数

从特定字段中删除引号 – 引号之间的整数,第1张

概述从特定字段中删除引号 – 引号之间的整数

我想从引号之间有整数的特定字段中删除引号。

从这一行: "AAA","99"

到这一行: "AAA",99

win7 express Js:'express'在cmd中无法识别

linux重命名命令大写的第一个字母

htaccess中的mod_rewrite:防止循环的最好方法?

在PowerShell中,如何将环境variables(如$ SystemRoot $)转换为string的一部分?

windowsbatch file中的正则Expression式

在windows系统中recursion重命名文件夹和文件

如果文件或目录存在,则RewriteCond跳过规则

奇怪的BUG – std :: regex只匹配前两个string

我怎样才能轻松获得在C中的正则Expression式select?

使用Python分割ps的输出

使用sed :

s='"AAA","99"' sed 's/"([0-9]*)"/1/g' <<< "$s" "AAA",99

试试这个GNU sed:

echo '"AAA","99"' | sed -E 's/"([0-9]+)"$/1/'

输出:

“AAA”,99

用awk:

awk -F,'BEGIN { OFS = FS } $2 ~ /^"[0-9]+"$/ { gsub(/"/,"",$2) } 1'

这工作如下:

BEGIN { OFS = FS } # Delimit output the same way as the input $2 ~ /^"[0-9]+"$/ { # if the second fIEld ($2) consists of only numbers encased # by double quotes (IE,matches the regex ^"[0-9]"$) gsub(/"/,$2) # remove the quotes from it } 1 # print in any case

为了使任何工作(而不仅仅是一个特定的领域),做一个循环替换:

awk -F,'BEGIN { OFS = FS } { for(i = 1; i <= NF; ++i) if($i ~ /^"[0-9]+"$/) { gsub(/"/,$i) } } 1'

这里改变的一点是

{ # Do this unconditionally in every line: for(i = 1; i <= NF; ++i) { # wade through all the fIElds if($i ~ /^"[0-9]+"$/) { # then do with them the same thing as before. gsub(/"/,$i) } } }

总结

以上是内存溢出为你收集整理的从特定字段中删除引号 – 引号之间的整数全部内容,希望文章能够帮你解决从特定字段中删除引号 – 引号之间的整数所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/1269083.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-08
下一篇 2022-06-08

发表评论

登录后才能评论

评论列表(0条)

保存