You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SUBST documentation is completely missing, so I wrote it myself (doing the usual reverse-engineering of the code.) Before integrating it, it's best to wait for #560 to merge (God willing.)
rule SUBST ( string regexp replacements + )
Replaces the string matching the regexp with all replacements.
The regexp argument accepts a regular expression of the same type as those used by the MATCH rule.
In replacements, the placeholders \0 and $0 are replaced with the full matched string, while \N and $N are replaced with the substring matched by group (() regexp subexpression) N-th. Currently only 9 groups are supported, so $10 in a replacement is interpreted as $1 followed by a '0' character.
Note that unlike MATCH, regexp does not have to contain a group for a result to be returned.
The Issue
The \ and $ characters in replacements disappear when they are not in placeholders.
As the following Jamfile demonstrates:
If you see a 🐞 in the issue heading it's because my browser doesn't support label management. René please put the label you think is appropriate.
Note
I've already written the code that fixes the problem and a new dedicated test, as well as the missing documentation. Normally, for a matter like this, I would have written a PR directly, but I already have too many submitted, some of which have been waiting months.
SUBST documentation is completely missing, so I wrote it myself (doing the usual reverse-engineering of the code.) Before integrating it, it's best to wait for #560 to merge (God willing.)
rule SUBST ( string regexp replacements + )Replaces the string matching the regexp with all replacements.
The regexp argument accepts a regular expression of the same type as those used by the
MATCHrule.In replacements, the placeholders
\0and$0are replaced with the full matched string, while\Nand$Nare replaced with the substring matched by group (()regexp subexpression) N-th. Currently only 9 groups are supported, so$10in a replacement is interpreted as$1followed by a '0' character.Note that unlike
MATCH, regexp does not have to contain a group for a result to be returned.The Issue
The
\and$characters in replacements disappear when they are not in placeholders.As the following Jamfile demonstrates:
gives:
instead of the expected:
Note
If you see a 🐞 in the issue heading it's because my browser doesn't support label management. René please put the label you think is appropriate.
Note
I've already written the code that fixes the problem and a new dedicated test, as well as the missing documentation. Normally, for a matter like this, I would have written a PR directly, but I already have too many submitted, some of which have been waiting months.