diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2017-09-12 22:00:51 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2017-09-12 22:00:51 -0700 |
commit | 497a4a70220bb982c68e80e547e7fd100bea8736 (patch) | |
tree | c78296699418851c25d02b1316af92e25e496131 | |
parent | 3cf766e87cacc93456e46d00a602a3f8915f9918 (diff) | |
download | txr-497a4a70220bb982c68e80e547e7fd100bea8736.tar.gz txr-497a4a70220bb982c68e80e547e7fd100bea8736.tar.bz2 txr-497a4a70220bb982c68e80e547e7fd100bea8736.zip |
doc: more notes on regex % operator syntax.
* txr.1: The dual precedence of % leads to surprises;
when parentheses are used around % expressions, they don't
behave symmetrically on both sides.
-rw-r--r-- | txr.1 | 34 |
1 files changed, 34 insertions, 0 deletions
@@ -2502,6 +2502,40 @@ is .B not equivalent to .codn (R1%)R2 . +Also note that +.code A(XY%Z)B +is equivalent to +.codn AX(Y%Z)B . +This is because the precedence of +.code % +is higher than that of catenation on its left side; this rule prevents the given +syntax from expressing the +.code XY +catenation. The expression may be understood as: +.code A(X(Y%Z))B +where the inner parentheses clarify how the syntax surrounding the +.code % +operator is being parsed, and the outer parentheses are superfluous. +The correct way to assert catenation of +.code XY +as the left operand of +.code % +is +.codn A(XY)%ZB . +To specify +.code XY +as the left operand, and limit the right operand to just +.codn Z , +the correct syntax is +.codn A((XY)%Z)B . +By contrast, the expression +.code A(X%YZ)B +is not equivalent to +.code A(X%Y)ZB +because the precedence of +.code % +is lower than that of catenation on its right side. The operator is +effectively "bi-precedential". .coIP ~R Match the opposite of the following expression .codn R ; |