Compare commits

...

2 Commits

Author SHA1 Message Date
9041f3a804 Adding regex tool 2025-07-12 19:16:12 -04:00
719ab8a02e Adding regex tool 2025-07-12 14:44:38 -04:00
9 changed files with 1847 additions and 0 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
node_modules node_modules
.env .env
tools/ProfanityFilter/src/Words.json

View File

@ -0,0 +1,25 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "java",
"name": "Current File",
"request": "launch",
"mainClass": "${file}"
},
{
"type": "java",
"name": "RegexGenerator",
"request": "launch",
"mainClass": "RegexGenerator",
"projectName": "ProfanityFilter_ceb3bd68",
"args": [
"ass",
"shit"
]
}
]
}

View File

@ -0,0 +1,7 @@
{
"java.project.sourcePaths": ["src"],
"java.project.outputPath": "bin",
"java.project.referencedLibraries": [
"lib/**/*.jar"
]
}

View File

@ -0,0 +1,18 @@
## Getting Started
Welcome to the VS Code Java world. Here is a guideline to help you get started to write Java code in Visual Studio Code.
## Folder Structure
The workspace contains two folders by default, where:
- `src`: the folder to maintain sources
- `lib`: the folder to maintain dependencies
Meanwhile, the compiled output files will be generated in the `bin` folder by default.
> If you want to customize the folder structure, open `.vscode/settings.json` and update the related settings there.
## Dependency Management
The `JAVA PROJECTS` view allows you to manage your dependencies. More details can be found [here](https://github.com/microsoft/vscode-java-dependency#manage-dependencies).

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,32 @@
public class ExceptionGenerator {
public static void main(String[] args) {
//position 0 should be the base word, the rest should be exceptions
String base = args[0].toLowerCase();
String prefixes = "(?<!";
String regex = RegexGenerator.regexGenerator(base);
String suffixes = "(?!";
for (int i = 1; i < args.length; i++) {
args[i] = "$" + args[i] + "$";
String prefix = args[i].toLowerCase().split(base)[0];
String suffix = args[i].toLowerCase().split(base)[1];
if (!prefix.equals("$")) {
prefixes += RegexGenerator.regexGenerator(prefix) + "|";
}
if (!suffix.equals("$")) {
suffixes += RegexGenerator.regexGenerator(suffix) + "|";
}
}
prefixes = prefixes.substring(0, prefixes.length() - 1);
suffixes = suffixes.substring(0, suffixes.length() - 1);
System.out.println(prefixes + ")" + regex + suffixes + ")");
}
}

View File

@ -0,0 +1,75 @@
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
public class RegexGenerator {
private static Map<Character, String> dictionary;
static {
Map<Character, String> map = new HashMap<>();
map.put('a', "[a@*]");
map.put('b', "([b38]|\\\\|3)");
map.put('c', "[c(k]");
map.put('d', "[d]");
map.put('e', "[e3*]");
map.put('f', "([f]|ph)");
map.put('g', "[g]");
map.put('h', "[h]");
map.put('i', "[il1!*]");
map.put('j', "[j]");
map.put('k', "[kc]");
map.put('l', "[li]");
map.put('m', "([m]|rn)");
map.put('n', "[n]");
map.put('o', "[o0pq*]");
map.put('p', "[p]");
map.put('q', "[q]");
map.put('r', "[r]");
map.put('s', "[sz5$]");
map.put('t', "[t7+]");
map.put('u', "[uv*]");
map.put('v', "[v]");
map.put('w', "([w]|vv)");
map.put('x', "[x]");
map.put('y', "[y]");
map.put('z', "[z]");
map.put(' ', "");
map.put('1', "([1]|one)");
map.put('2', "([2]|two)");
map.put('3', "([3]|three)");
map.put('4', "([4]|four)");
map.put('5', "([5]|five)");
map.put('6', "([6]|six)");
map.put('7', "([7]|seven)");
map.put('8', "([8]|eight)");
map.put('9', "([9]|nine)");
map.put('0', "([0]|zero)");
dictionary = Collections.unmodifiableMap(map);
}
public static void main(String[] args) {
for (String s : args) {
String regex = "(\\\\b|^)";
for (char c : s.toLowerCase().toCharArray()) {
regex += dictionary.get(c) + "+[\\\\s\\\\n\\\\W]*";
}
regex += "(\\\\b|$)";
System.out.println(regex);
}
}
public static String regexGenerator(String str) {
String regex = "(\\\\b|^)";
for (char c : str.toLowerCase().toCharArray()) {
regex += dictionary.get(c) + "+[\\\\s\\\\n\\\\W]*";
}
regex += "(\\\\b|$)";
return regex;
}
}