【问题标题】:[[:jletterdigit:]] to classical regex[[:jletterdigit:]] 到经典正则表达式
【发布时间】:2011-01-05 14:53:35
【问题描述】:

JFlex 的 [[:jletterdigit:]] 中有哪些字符? 我需要将 [[:jletterdigit:]] 翻译成经典的正则表达式。

【问题讨论】:

    标签: java jflex


    【解决方案1】:

    澄清迈克尔·洛曼的回答: 这就是the JFlex documentation 所说的:

    jletter 和 jletterdigit 是预定义的字符类。 jletter 包括 Java 函数 Character.isJavaIdentifierStart 为其返回 true 的所有字符,jletterdigit 包含该 Character.isJavaIdentifierPart 为其返回 true 的所有字符。

    而他写的是documentation of Character.isJavaIdentifierPart

    确定指定字符是否可能是 Java 标识符的一部分 除了第一个字符。

    如果满足以下任一条件,则字符可能是 Java 标识符的一部分 是真的:

    it is a letter
    it is a currency symbol (such as '$')
    it is a connecting punctuation character (such as '_')
    it is a digit
    it is a numeric letter (such as a Roman numeral character)
    it is a combining mark
    it is a non-spacing mark
    isIdentifierIgnorable returns true for the character
    

    isIdentifierIgnorable 又被定义为:

    确定指定的字符(Unicode 代码点)是否应为 被视为 Java 标识符或 Unicode 中的可忽略字符 标识符。

    以下 Unicode 字符在 Java 标识符中可以忽略或 Unicode 标识符:

    ISO control characters that are not whitespace
        '\u0000' through '\u0008'
        '\u000E' through '\u001B'
        '\u007F' through '\u009F' 
    all characters that have the FORMAT general category value
    

    【讨论】:

      【解决方案2】:

      如果满足以下任一条件,则字符可能是 Java 标识符的一部分:

      这是一个字母

      它是一个货币符号(例如'$')

      是连接标点符号(如'_')

      这是一个数字

      是数字字母(如罗马数字字符)

      它是一个组合标记

      它是一个非间距标记

      isIdentifierIgnorable 为字符返回 true

      from the Java API

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-09-28
        • 2012-01-16
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多