How do I properly perform a string pattern match in the way that I want it to?

I want to achieve string pattern match-based username and display name banning.

local http = game:GetService("HttpService")
local plrs = game:GetService("Players")

local watch_sets = {
	target_username = "AnonymizedUsername",
	target_dispname = "AnonymizedDisplayName",
	shirt = 144076436,
	pants = 144076512,
	patterns = {
		"Parker%d%d$", -- ends with two digits after "Parker"
		".*Parker%d%d$", -- starts with anything, and ends with two digits after "Parker"
		"%u%d%d%dParker%d%d$" -- starts with an uppercase letter followed by three digits and ends with two digits after "Parker"

local kick_reasons = {
	"The experience's developer has temporarily shut down the experience server. Please try again.",
	"Roblox has shut down the server for maintenance. Please try again.",
	"Please check your internet connection and try again.",
	"Client initiated disconnect",
	"Your device does not have enough memory to run this experience. Exit back to the app.",
	"The status of the experience has changed and you no longer have access. Please try again later.",	

local hooks = {
	url = "<webhook url removed>",
	trig_meth = {
		gen = "Possible (Username, DisplayName)";
		com = "Confident (Username, DisplayName, Clothes)";
		noti = "<@Discord User ID Removed>";
	hookd = {
		username = "",
		title = [[Username: %s
Display Name: %s
User ID: %d
Trigger Method: %s]],
		type = "rich",

local function matchesAnyPattern(username, patterns)
	for _, pattern in ipairs(patterns) do
		if string.match(username, pattern) then
			return true
	return false

local function check_outfit(plr: Player)
	local hum_des = plrs:GetHumanoidDescriptionFromUserId(plr.UserId)

	if hum_des.Shirt == watch_sets.shirt and hum_des.Pants == watch_sets.pants then
		return true
		return false 

local function check_name(plr: Player)
	local disp_name,username = plr.DisplayName,plr.Name
	if matchesAnyPattern(username,watch_sets.patterns) 
		or string.find(disp_name,watch_sets.target_dispname,1,true) 
		or string.find(username,watch_sets.target_username,1,true) 
			return true
			return false

local function send_wh(plr: Player, tm: string)
	local enc = http:JSONEncode({
		embeds = {{
			username = "";
			title = string.format(hooks.hookd.title,plr.Name,plr.DisplayName,plr.UserId,tm);
			type = "rich";
	local req = http:RequestAsync({
		Url = hooks.url,
		Method = "POST",
		Headers = {
			["Content-Type"] = "application/json";
		Body = enc

local function add_loop(plr: Player)
	local out,name = check_outfit(plr),check_name(plr)
	if out and name then
	if name then


This is the entire script I’m using for posterity. For a focus on what I wish to accomplish, please pay attention to the target_username and target_dispname, and how basic the original username/DisplayName checking function is. It only performs a strict string match at the moment.

I wish to have this string, somehow, matched, regardless of how many character repetitions ('AnonnymizedUserrrname instead of AnonymizedUsername) are in the original string.

Any help is appreciated, and if none can be lended at all, that’s also okay.


local baseName = "NoobDork"

local exp = ""

for i = 1, #baseName do
  local chr = string.sub(baseName, i, i)

  exp = exp .. "[" ..chr.. "]+"


local slickName = "NoooobDooooork"

print(string.match(slickName, exp))

Keep in mind that someone who knows you’re doing this can very easily get other people banned on purpose. For example with .*Parker%d%d I could match your name by getting an account named “randan” banned.

1 Like

Those expressions work, and are just for the username. I’m processing both the DisplayName, and the Username, as a two-condition and statement

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.