Logo

Programming-Idioms

History of Idiom 151 > diff from v15 to v16

Edit summary for version 16 by REUSS:
New Lua implementation by user [REUSS]

Version 15

2019-10-08, 21:14:43

Version 16

2020-05-29, 15:13:55

Idiom #151 Remove string trailing path separator

Remove last character from string p, if this character is the file path separator of current platform.

Note that this also transforms unix root path "/" into empty string!

Idiom #151 Remove string trailing path separator

Remove last character from string p, if this character is the file path separator of current platform.

Note that this also transforms unix root path "/" into empty string!

Variables
p
Extra Keywords
trim
Extra Keywords
trim
Code
if string.sub(p, -1, -1) == "/" then
	p=string.sub(p, 1, -2)
end
Comments bubble
"/" is tolerated by io library regardless of a platform.