IEEE Standards Interpretations for IEEE Std 1003.2™-1992 IEEE Standard for Information Technology--Portable Operating System Interfaces (POSIX®)--Part 2: Shell and Utilities
Copyright © 1996 by the Institute of Electrical and Electronics Engineers, Inc. 3 Park Avenue New York, New York 10016-5997 USA All Rights Reserved.
Interpretations are issued to explain and clarify the intent of a standard and do not constitute an alteration to the original standard. In addition, interpretations are not intended to supply consulting information. Permission is hereby granted to download and print one copy of this document. Individuals seeking permission to reproduce and/or distribute this document in its entirety or portions of this document must contact the IEEE Standards Department for the appropriate license. Use of the information contained in this document is at your own risk.
IEEE Standards Department, Copyrights and Permissions, 445 Hoes Lane, Piscataway, New Jersey 08855-1331, USA
Interpretation Request #82
Topic: BRE Relevant Clauses: 2.8.3
POSIX.2 Subclause 126.96.36.199 item (3) specifies the semantics of backreference expressions in Basic Regular Expressions. This subclause states in part: The backreference expression \n shall match the same (possibly empty) string of characters as was matched by a subexpression enclosed between \( and \) preceding the \n. Suppose that the subexpression includes an anchor, and suppose that the system in question is one on which anchoring characters act as anchors in subexpressions. Does the backreference expression have to match an anchored string? (In this case, it can never match anything unless the first subexpression matched an empty string.) For example, on such a system does the BRE \(^b\)\1 match the first two characters of bbbbb or is the BRE to be treated as equivalent to \(^b\)\(^b\) (in which case it will not match)?
The standard clearly states the behaviour for BREs, and conforming implementations must conform to this. In the example provided, the standard permits matching, but does not require it.
Rationale for Interpretation