Neat, it works like clockwork. Can you please share where I can learn these '\n', '\\n', '\r?', '%s', '%s$' like stuff?pgimeno wrote: ↑Fri Jan 31, 2020 9:11 pm Oh OK, so what you want is probably this:Applied to your example:Code: Select all
love.filesystem.read():gsub('\r?\n', ''):gsub('\\n', '\n')
Mind you, it doesn't work for any other escape.Code: Select all
s = [[Hello World. This is a test file which contains some text.\n Thanks, bye! ]] print((s:gsub('\r?\n', ''):gsub('\\n', '\n'))) --[[ prints: Hello World.This is a test file which contains some text. Thanks, bye! --]]
Can love.filesystem.read skip custom linebreaks?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: Can love.filesystem.read skip custom linebreaks?
- zorg
- Party member
- Posts: 3444
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: Can love.filesystem.read skip custom linebreaks?
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
Re: Can love.filesystem.read skip custom linebreaks?
I think the Lua manual is more relevant here, because there are some differences (most notably, that \123 takes decimal numbers instead of octal):
Patterns: see Lua manual 5.4.1 (these are only used with string.gsub, string.gmatch, string.match, string.find and the obsolete alias string.gfind)
Backslash escapes apply to every literal string, see Lua manual 2.1
(Note: The version of LuaJIT that comes with LÖVE has some Lua 5.2 extensions, including hexadecimal backslash escapes of the form \x2A, you can read about them here: LuaJIT extensions)
Patterns: see Lua manual 5.4.1 (these are only used with string.gsub, string.gmatch, string.match, string.find and the obsolete alias string.gfind)
Backslash escapes apply to every literal string, see Lua manual 2.1
(Note: The version of LuaJIT that comes with LÖVE has some Lua 5.2 extensions, including hexadecimal backslash escapes of the form \x2A, you can read about them here: LuaJIT extensions)
Who is online
Users browsing this forum: Ahrefs [Bot], Google [Bot] and 87 guests