What is a compact way of removing the last part of a string after the last occurrence of a given substring, including it? In terms of bash parameter substitution it would be the equivalent of:
VAR=${VAR%substring*}
Is there a library (e.g. boost) supporting replacement with wildcards or something similar?