<commit_before>var ignoredSymbols = "[\\*\\^\\$]"

function has(string, input) {
	if (!input) {
		if (string == "numbers" || string == "digits" || string == "num") return '(?=.*[0-9])'
		if (string == "letters" || string == "char") return '(?=.*[a-zA-Z])'
		
		if (string == "$numbers" || string == "$digits" || string == "$num" || string == "$letters" || string == "$char") {
			return '(?=.*\\b' + string.substring(1) + '\\b.*)'
		}

		if (string.match(ignoredSymbols)) {
			for (i = 0; i < string.match(new RegExp(ignoredSymbols, 'g')).length; i++) {
				var metaChar = string.match(new RegExp(ignoredSymbols, 'g'))[i]
				    string = string.replace(metaChar, "\\" + metaChar)
			}
			return new RegExp(string)
		} else {
			return '(?=.*\\b' + string + '\\b.*)'
		}
	} else {
		if (string.match(ignoredSymbols)) {
			for (i = 0; i < string.match(new RegExp(ignoredSymbols, 'g')).length; i++) {
				var metaChar = string.match(new RegExp(ignoredSymbols, 'g'))[i]
				    string = string.replace(metaChar, "\\" + metaChar)
			}
		}
		return input.match(new RegExp(string, 'gi')).length			
	}
}
function not(string) {
	if (string == "numbers" || string == "digits" || string == "num") return '(?=.*^([^0-9]*)$)'
	if (string == "letters" || string == "char") return '(?=.*^([^a-zA-Z]*)$)'

	if (string == "$numbers" || string == "$digits" || string == "$num" || string == "$letters" || string == "$char") {
		return '(?=.*^(?!.*' + string.substring(1) + ').*$)'
	}

	if (string.match(ignoredSymbols)) {
		for (i = 0; i < string.match(new RegExp(ignoredSymbols, 'g')).length; i++) {
			var metaChar = string.match(new RegExp(ignoredSymbols, 'g'))[i]
				string = string.replace(metaChar, "\\" + metaChar)
		}
	}
	return '(?=.*^(?!.*' + string + ').*$)'
}
function beginsWith(string, input) {
	if (!input) {
		if (string.match(ignoredSymbols)) {
			for (i = 0; i < string.match(new RegExp(ignoredSymbols, 'g')).length; i++) {
				var metaChar = string.match(new RegExp(ignoredSymbols, 'g'))[i]
					string = string.replace(metaChar, "\\" + metaChar)
			}
		}
		return '(?=\\b' + string + ')'
	} else {
		if (string.match(ignoredSymbols)) {
			for (i = 0; i < string.match(new RegExp(ignoredSymbols, 'g')).length; i++) {
				var metaChar = string.match(new RegExp(ignoredSymbols, 'g'))[i]
					string = string.replace(metaChar, "\\" + metaChar)
			}
		}
		return input.match(new RegExp('\\b' + string, 'g')).length
	}
}
function endsWith(string, input) {
	if (!input) {
		if (string.match(ignoredSymbols)) {
			for (i = 0; i < string.match(new RegExp(ignoredSymbols, 'g')).length; i++) {
				var metaChar = string.match(new RegExp(ignoredSymbols, 'g'))[i]
					string = string.replace(metaChar, "\\" + metaChar)
			}
		}
		return '(?=\\B' + string + ')'
	} else {
		if (string.match(ignoredSymbols)) {
			for (i = 0; i < string.match(new RegExp(ignoredSymbols, 'g')).length; i++) {
				var metaChar = string.match(new RegExp(ignoredSymbols, 'g'))[i]
					string = string.replace(metaChar, "\\" + metaChar)
			}
		}
		return input.match(new RegExp('\\B' + string, 'g')).length
	}
}
function wordSize(size, input) {
	if (!input) {
		return '(?=[a-zA-Z0-9]{' + size + '})'
	} else {
		return input.match(new RegExp('[a-z0-9]{' + size + '}', 'gi')).length	
	}
}
function or() {
	return '|'
}
// does not work with or() and + 
function atLeastOne(string) {
	if (string.match(ignoredSymbols)) {
		for (i = 0; i < string.match(new RegExp(ignoredSymbols, 'g')).length; i++) {
			var metaChar = string.match(new RegExp(ignoredSymbols, 'g'))[i]
				string = string.replace(metaChar, "\\" + metaChar)
		}
	}
	return new RegExp('(?=' + string + '+)', 'g')
}
function showRegex(string) { 
	return eval(string)
}<commit_msg>Update easy-regex.js<commit_after>//meta-characters that bring errors when used in a function's parameter
var ignoredSymbols = "[\\*\\^\\$]"

function has(string, input) {
	if (!input) {
		if (string == "numbers" || string == "digits" || string == "num") return '(?=.*[0-9])'
		if (string == "letters" || string == "char") return '(?=.*[a-zA-Z])'

		if (string == "$numbers" || string == "$digits" || string == "$num" || string == "$letters" || string == "$char") {
			return '(?=.*\\b' + string.substring(1) + '\\b.*)'
		}
		//loop that checks for meta chars and adds a backlash for everyone that is found
		if (string.match(ignoredSymbols)) {
			for (i = 0; i < string.match(new RegExp(ignoredSymbols, 'g')).length; i++) {
				//replaces each meta-char with '\\' to prevent errors
				string = string.replace(string.match(new RegExp(ignoredSymbols, 'g'))[i], "\\" + string.match(new RegExp(ignoredSymbols, 'g'))[i])
			}
		}
		return '(?=.*\\b' + string + '\\b.*)'
	} else {
		if (string.match(ignoredSymbols)) {
			for (i = 0; i < string.match(new RegExp(ignoredSymbols, 'g')).length; i++) {
				string = string.replace(string.match(new RegExp(ignoredSymbols, 'g'))[i], "\\" + string.match(new RegExp(ignoredSymbols, 'g'))[i])
			}
		}
		return input.match(new RegExp(string, 'gi')).length			
	}
}
function not(string) {
	if (string == "numbers" || string == "digits" || string == "num") return '(?=.*^([^0-9]*)$)'
	if (string == "letters" || string == "char") return '(?=.*^([^a-zA-Z]*)$)'

	if (string == "$numbers" || string == "$digits" || string == "$num" || string == "$letters" || string == "$char") {
		return '(?=.*^(?!.*' + string.substring(1) + ').*$)'
	}

	if (string.match(ignoredSymbols)) {
		for (i = 0; i < string.match(new RegExp(ignoredSymbols, 'g')).length; i++) {
			string = string.replace(string.match(new RegExp(ignoredSymbols, 'g'))[i], "\\" + string.match(new RegExp(ignoredSymbols, 'g'))[i])
		}
	}
	return '(?=.*^(?!.*' + string + ').*$)'
}
function beginsWith(string, input) {
	if (!input) {
		if (string.match(ignoredSymbols)) {
			for (i = 0; i < string.match(new RegExp(ignoredSymbols, 'g')).length; i++) {
				string = string.replace(string.match(new RegExp(ignoredSymbols, 'g'))[i], "\\" + string.match(new RegExp(ignoredSymbols, 'g'))[i])
			}
		}
		return '(?=\\b' + string + ')'
	} else {
		if (string.match(ignoredSymbols)) {
			for (i = 0; i < string.match(new RegExp(ignoredSymbols, 'g')).length; i++) {
				string = string.replace(string.match(new RegExp(ignoredSymbols, 'g'))[i], "\\" + string.match(new RegExp(ignoredSymbols, 'g'))[i])
			}
		}
		return input.match(new RegExp('\\b' + string, 'g')).length
	}
}
function endsWith(string, input) {
	if (!input) {
		if (string.match(ignoredSymbols)) {
			for (i = 0; i < string.match(new RegExp(ignoredSymbols, 'g')).length; i++) {
				string = string.replace(string.match(new RegExp(ignoredSymbols, 'g'))[i], "\\" + string.match(new RegExp(ignoredSymbols, 'g'))[i])
			}
		}
		return '(?=\\B' + string + ')'
	} else {
		if (string.match(ignoredSymbols)) {
			for (i = 0; i < string.match(new RegExp(ignoredSymbols, 'g')).length; i++) {
				string = string.replace(string.match(new RegExp(ignoredSymbols, 'g'))[i], "\\" + string.match(new RegExp(ignoredSymbols, 'g'))[i])
			}
		}
		return input.match(new RegExp('\\B' + string, 'g')).length
	}
}
function wordSize(size, input) {
	if (!input) {
		return '(?=[a-zA-Z0-9]{' + size + '})'
	} else {
		return input.match(new RegExp('[a-z0-9]{' + size + '}', 'gi')).length	
	}
}
function or() {
	return '|'
}
// does not work with or() and + 
function atLeastOne(string) {
	if (string.match(ignoredSymbols)) {
		for (i = 0; i < string.match(new RegExp(ignoredSymbols, 'g')).length; i++) {
			string = string.replace(string.match(new RegExp(ignoredSymbols, 'g'))[i], "\\" + string.match(new RegExp(ignoredSymbols, 'g'))[i])
		}
	}
	return new RegExp('(?=' + string + '+)', 'g')
}
function showRegex(string) { 
	return eval(string)
}
{'fraction_non_alphanumeric': 0.23593017196456487, 'fraction_numerical': 0.004689942678478374, 'mean_word_length': 3.816185696361355, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1731419', 'n_tokens_mistral': 3188, 'n_tokens_neox': 2910, 'n_words': 601}