C++ Standard Library / std::tr1::wregex / Inkorrektes Verhalten der '\b'-Assertion

常规讨论 C++ Standard Library / std::tr1::wregex / Inkorrektes Verhalten der '\b'-Assertion

  • Donnerstag, 2. Februar 2012 09:53
     
     

    Der reguläre Ausdruck L"ä\\b" passt auf den Text L"Sozietät"!

    Das bedeutet, dass std::tr1::wregex den Wechsel vom Unicode "Extended Latin Block", in dem sich das 'ä' befindet, zum Unicode "Basic Latin Block", in dem sich das 't' befindet, als "Word Boundary" ('\b') interpretiert.

    Ich gehe davon aus, dass es sich hierbei um einen BUG in der IsWordChar-Funktion handelt. Hierzu sagt der ECMA-262 Standard V5.1, Kapitel 15.10.2.6:

    The production Assertion :: \ b evaluates by returning an internal AssertionTester closure that takes a State argument x and performs the following:

    1. Let e be x's endIndex.
    2. Call IsWordChar(e–1) and let a be the Boolean result.
    3. Call IsWordChar(e) and let b be the Boolean result.
    4. If a is true and b is false, return true.
    5. If a is false and b is true, return true.
    6. Return false.

    The production Assertion :: \ B evaluates by returning an internal AssertionTester closure that takes a State argument x and performs the following:

    1. Let e be x's endIndex.
    2. Call IsWordChar(e–1) and let a be the Boolean result.
    3. Call IsWordChar(e) and let b be the Boolean result.
    4. If a is true and b is false, return false.
    5. If a is false and b is true, return false.
    6. Return true.

    Sowohl PCRE als auch "java.util.regex.Pattern" leiden nicht an dieser Krankheit.

     

Alle Antworten