【问题标题】:regex negation in antant中的正则表达式否定
【发布时间】:2012-08-02 03:41:55
【问题描述】:

我正在尝试计算文件中不包含以下行的行数:

/*================================================= */

Number of current users:

或 空行

我可以计算包含LIB 的行数,

<propertyregex property="noOfUsers"
               input="@{line}"
               regexp="Number of current users:\s*([0-9]+)$"
               select="\1" />

但是,我无法推导出否定表达式。有人可以帮我解决这个正则表达式吗?

【问题讨论】:

标签: regex ant regex-negation regex-greedy


【解决方案1】:
  1. 这是查找注释行的模式,例如/* anything * /。在您的语言中使用以下模式,通过循环您可以找到注释行的数量。

    模式:/^[/][*].*[*][/]$/

  2. 要查找空行,您可以使用以下模式

    模式:/^\n/

谢谢, 阿伦

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-01-13
    • 1970-01-01
    • 1970-01-01
    • 2016-01-21
    相关资源
    最近更新 更多