s4_right( string, n )
Expands to n characters from the right side of the string:
⇐ {s4_right([String], [3])}
⇒ {ing}
Leading and trailing whitespace is trimmed from n:
⇐ {s4_right([String], [
⇐ 3
⇐ ])}
⇒ {ing}
n can be signed, both plus and minus signs are allowed:
⇐ {s4_right([String], [+3])}
⇒ {ing}
If n is zero or negative, result is empty:
⇐ {s4_right([String], [-3])}
⇒ {}
If n is greather than string length, entire string is returned:
⇐ {s4_right([String], [10])}
⇒ {String}
Result is quoted:
⇐ {s4_right([m4_toupper([String])], [20])}
⇒ {m4_toupper([String])}
(Note: m4_toupper
macro is not expanded.)
Beware: M4 v1.4.18 is not Unicode-aware, it considers every single byte as a character. So,
using s4_right
with non-ASCII strings can produce misleading result and/or invalid Unicode.
⇐ {s4_right([Фыва], [4])}
⇒ {ва}
(Note: 4 characters requested but 2 characters actually returned. Requesting odd number of characters will likely cause invalid Unicode.)