Error[8]: Undefined offset: 4, File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 121
File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 473, decode(

概述我想从某个文件中删除非ascii字符.我已经尝试了这么多正则表达式.sed -e 's/[\d00-\d128]//g' # not working cat /bin/mkdir | sed -e 's/[\x00-\x7F]//g' >/tmp/aa 但是这个文件包含一些非ascii字符.[root@asssdsada ~]$hexdump /t

我想从某个文件中删除非ascii字符.我已经尝试了这么多正则表达式.

sed -e 's/[\d00-\d128]//g'  # not workingcat /bin/mkdir | sed -e 's/[\x00-\x7F]//g' >/tmp/aa

但是这个文件包含一些非ascii字符.

[root@asssdsada ~]$hexdump /tmp/aa |more          00 01 02 03 04 05 06 07 - 08 09 0A 0B 0C 0D 0E 0F  0123456789ABCDEF00000000  45 4C 46 B0 F0 73 38 C0 - C0 BC BC FF FF 61 61 61  ELF..s8......aaa00000010  A0 A0 50 E5 74 64 50 57 - 50 57 50 57 D4 D4 51 E5  ..P.tdPWPWPW..Q.00000020  74 64 6C 69 62 36 34 6C - 64 6C 69 6E 75 78 78 38  tdlib64ldlinuxx800000030  36 36 34 73 6F 32 47 4E - 55 42 C8 C0 80 70 69 42  664so2GNUB...piB00000040  44 47 BA E3 92 43 45 D5 - EC 46 E4 DE D8 71 58 B9  DG...CE..F...qX.00000050  8D F1 EA D3 EF 4B 86 FC - A9 DA 79 ED 63 B5 51 92  .....K....y.c.Q.00000060  BA 6C FC D1 69 78 30 ED - 74 F1 73 95 CC 85 D2 46  .l..ix0.t.s....F00000070  A5 B4 6C 67 DA 4A E9 9A - 4B 58 77 A4 37 80 C0 4F  ..lg.J..KXw.7..O00000080  F3 E9 B2 77 65 97 74 F9 - A2 C0 F2 CC 4A 9C 58 A1  ...we.t.....J.X.
最佳答案这似乎不适用于sed.也许tr会做什么?

tr -d '0-7'

或补充:

tr -cd '[+++]0-7'
总结

以上是内存溢出为你收集整理的正则表达式 – 如何使用sed删除非ascii字符全部内容,希望文章能够帮你解决正则表达式 – 如何使用sed删除非ascii字符所遇到的程序开发问题。

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

)
File: /www/wwwroot/outofmemory.cn/tmp/route_read.php, Line: 126, InsideLink()
File: /www/wwwroot/outofmemory.cn/tmp/index.inc.php, Line: 166, include(/www/wwwroot/outofmemory.cn/tmp/route_read.php)
File: /www/wwwroot/outofmemory.cn/index.php, Line: 30, include(/www/wwwroot/outofmemory.cn/tmp/index.inc.php)
正则表达式 – 如何使用sed删除非ascii字符_系统运维_内存溢出

正则表达式 – 如何使用sed删除非ascii字符

正则表达式 – 如何使用sed删除非ascii字符,第1张

概述我想从某个文件中删除非ascii字符.我已经尝试了这么多正则表达式.sed -e 's/[\d00-\d128]//g' # not working cat /bin/mkdir | sed -e 's/[\x00-\x7F]//g' >/tmp/aa 但是这个文件包含一些非ascii字符.[root@asssdsada ~]$hexdump /t

我想从某个文件中删除非ascii字符.我已经尝试了这么多正则表达式.

sed -e 's/[\d00-\d128]//g'  # not workingcat /bin/mkdir | sed -e 's/[\x00-\x7F]//g' >/tmp/aa

但是这个文件包含一些非ascii字符.

[root@asssdsada ~]$hexdump /tmp/aa |more          00 01 02 03 04 05 06 07 - 08 09 0A 0B 0C 0D 0E 0F  0123456789ABCDEF00000000  45 4C 46 B0 F0 73 38 C0 - C0 BC BC FF FF 61 61 61  ELF..s8......aaa00000010  A0 A0 50 E5 74 64 50 57 - 50 57 50 57 D4 D4 51 E5  ..P.tdPWPWPW..Q.00000020  74 64 6C 69 62 36 34 6C - 64 6C 69 6E 75 78 78 38  tdlib64ldlinuxx800000030  36 36 34 73 6F 32 47 4E - 55 42 C8 C0 80 70 69 42  664so2GNUB...piB00000040  44 47 BA E3 92 43 45 D5 - EC 46 E4 DE D8 71 58 B9  DG...CE..F...qX.00000050  8D F1 EA D3 EF 4B 86 FC - A9 DA 79 ED 63 B5 51 92  .....K....y.c.Q.00000060  BA 6C FC D1 69 78 30 ED - 74 F1 73 95 CC 85 D2 46  .l..ix0.t.s....F00000070  A5 B4 6C 67 DA 4A E9 9A - 4B 58 77 A4 37 80 C0 4F  ..lg.J..KXw.7..O00000080  F3 E9 B2 77 65 97 74 F9 - A2 C0 F2 CC 4A 9C 58 A1  ...we.t.....J.X.
最佳答案这似乎不适用于sed.也许tr会做什么?

tr -d '0-7'

或补充:

tr -cd '0-7'
总结

以上是内存溢出为你收集整理的正则表达式 – 如何使用sed删除非ascii字符全部内容,希望文章能够帮你解决正则表达式 – 如何使用sed删除非ascii字符所遇到的程序开发问题。

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

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

原文地址: http://outofmemory.cn/yw/1047924.html

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

发表评论

登录后才能评论

评论列表(0条)

保存