【问题标题】:regex to find where '&' doesn't have ending semicolon [closed]正则表达式查找“​​&”没有结束分号的位置[关闭]
【发布时间】:2013-09-29 18:09:37
【问题描述】:

我有一个程序失败,因为我的 10,000 个 xml 文件中的一个在 & 之后没有分号。而且我不知道是哪个文件。

The reference to entity "L" must end with the ';' delimiter.

有没有办法在命令行 (linux) 上对不以分号结尾的 &L 进行正则表达式搜索?

或者快速脚本会更好吗?

【问题讨论】:

  • &L是指确切两个字符的长字符串&L,还是包含字符串&L的任意长度的字符串?
  • grep "&L[^;]" file?
  • 或者,grep "&[a-zA-Z][^;]" file?
  • @devnull,即使添加缺少的-P+'&abc;''♠' 也会失败。

标签: python xml regex linux perl


【解决方案1】:
grep --color=auto -P '&[\w#]+(?![\w#;])' *.xml

或者如果您只想要文件名:

grep -lP '&[\w#]+(?![\w#;])' *.xml

【讨论】:

    猜你喜欢
    • 2013-06-29
    • 1970-01-01
    • 2018-08-02
    • 1970-01-01
    • 1970-01-01
    • 2013-08-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多