I want to check if url is valid, what is the correct regexp to do that in lua? I tried regexp like this
string.match('https://stackoverflow.com/', '[a-z]*:\/\/[^ >,;]*')
but getting error
invalid escape sequence near ''[a-z]*:\/'
Update:
string.match('https://stackoverflow.com/', '[a-z]*://[^ >,;]*')
is correct answer
The error is fairly clear: \/
is an invalid escape. You don't need to escape /
, as it's not a special character in Lua patterns (check the list of "magic" characters) and removing the escape should work: string.match('https://stackoverflow.com/', '[a-z]*://[^ >,;]*')
.