s4_left(string, n)
Expands to n characters from the left side of the string:
⇐ {s4_left([String], [3])}
⇒ {Str}
Leading and trailing whitespace is trimmed from n:
⇐ {s4_left([String], [
⇐ 3
⇐ ])}
⇒ {Str}
n can be signed, both plus and minus signs are allowed:
⇐ {s4_left([String], [+3])}
⇒ {Str}
If n is zero or negative, result is empty:
⇐ {s4_left([String], [-3])}
⇒ {}
If n is greather than string length, entire string is returned:
⇐ {s4_left([String], [10])}
⇒ {String}
Result is quoted:
⇐ {s4_left([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_left
with non-ASCII strings can produce misleading result and/or invalid Unicode.
⇐ {s4_left([Фыва], [4])}
⇒ {Фы}
(Note: 4 characters requested but 2 characters actually returned. Requesting odd number of characters will likely cause invalid Unicode.)