function pattern_checker(v) return string.match(v, '^[%d%a_.]+$') ~= nil and -- check if the string only contains digits/letters/_, one or more string.sub(v, 0, 1) ~= '.' and -- check if the first char is not '.' string.sub(v, -1) ~= '.' and -- check if the last char is not '.' string.find(v, '%.%.') == nil -- check if there are 2 consecutive dots in the string end -- good examples print(pattern_checker("hello.com")) print(pattern_checker("hello")) print(pattern_checker("hello.com.com.com")) -- bad examples print(pattern_checker("hello.com.")) print(pattern_checker(".hello")) print(pattern_checker("hello..com.com.com")) print(pattern_checker("%hello.com.com.com"))