
Security News
Meet Socket at Black Hat and DEF CON 2025 in Las Vegas
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
net.codebox:readable-regex
Advanced tools
This library provides a way to make complex regular expressions in Java code more readable.
This library provides a way to make complex regular expressions in Java code more readable.
The best way to explain what it does to show some examples:
// Matches a single digit
RegExBuilder.build(anyDigit()); // "[0-9]"
// Matches exactly 2 digits
RegExBuilder.build(exactly(2).of(anyDigit())); // "[0-9]{2}"
// Matches between 2 and 4 letters
RegExBuilder.build(between(2,4).of(anyLetter())); // "[a-zA-Z]{2,4}"
Characters that have special meaning within a regular expression are escaped automatically:
// Matches one or more occurrences of the text 'Ho?'
RegExBuilder.build(oneOrMore().of("Ho?")); // "(Ho\?)+"
// Matches anything except an opening or closing square bracket, or a backslash
RegExBuilder.build(
anyCharacterExcept(
characters('[', ']','\\')
)
); // "[^[\\]\\\\]"
Readability is greatly improved for more complex expressions:
// More or less validates the format of an email address
// [_\\-A-Za-z0-9]+(\\.[_\\-A-Za-z0-9]+)*@[A-Za-z0-9]+(\\.[A-Za-z0-9]+)*\\.[a-zA-Z]{2,}
RegExBuilder.build(
oneOrMore().of(
anyOneOf(
characters('_','-'), range('A','Z'), range('a','z'), range('0','9')
)
),
zeroOrMore().of(
text("."),
oneOrMore().of(
anyOneOf(
characters('_','-'), range('A','Z'), range('a','z'), range('0','9')
)
)
),
text("@"),
oneOrMore().of(
anyOneOf(
range('A','Z'), range('a','z'), range('0','9')
)
),
zeroOrMore().of(
text("."),
oneOrMore().of(
anyOneOf(
range('A','Z'), range('a','z'), range('0','9')
)
)
),
text("."),
atLeast(2).of(
anyLetter()
)
);
All classes in the library are immutable, and therefore instances are re-usable and thread-safe.
FAQs
This library provides a way to make complex regular expressions in Java code more readable.
We found that net.codebox:readable-regex demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.