
Enhances regular expression creation with a type-safe, expressive DSL, supporting automatic character escaping, named groups, lookahead/lookbehind assertions, and common regex operations.
A Kotlin Multiplatform library that provides a DSL for writing regular expressions in a more readable and maintainable way.
implementation("io.github.stream29:regexdsl:0.0.1")See at examples.ipynb
buildRegex { ... }: Creates a Regex object using the DSLbuildRegexString { ... }: Returns the string representation of the regex patternmatch(string): Matches a literal string (automatically escaped)match(char): Matches a literal character (automatically escaped)match(regexElement): Matches a regex element (e.g., digitChar, wordChar)matchCharacterSet { ... }: Matches a character set (e.g., [abc])matchNegatedCharacterSet { ... }: Matches a negated character set (e.g., [^abc])matchStringBegin(): Matches the beginning of the string (^)matchStringEnd(): Matches the end of the string ($)matchWordBoundary(): Matches a word boundary (\b)matchNonWordBoundary(): Matches a non-word boundary (\B)matchIndexedGroup { ... }: Creates a capturing group ((...))matchNamedGroup(name) { ... }: Creates a named capturing group ((?<name>...))matchUncapturedGroup { ... }: Creates a non-capturing group ((?:...))lookahead { ... }: Creates a positive lookahead assertion ((?=...))lookaheadNegative { ... }: Creates a negative lookahead assertion ((?!...))lookbehind { ... }: Creates a positive lookbehind assertion ((?<=...))lookbehindNegative { ... }: Creates a negative lookbehind assertion ((?<!...))insertOr(): Inserts an alternation operator (|)anyChar: Matches any character (.)digitChar: Matches a digit character (\d)nonDigitChar: Matches a non-digit character (\D)wordChar: Matches a word character (\w)nonWordChar: Matches a non-word character (\W)spaceChar: Matches a whitespace character (\s)nonSpaceChar: Matches a non-whitespace character (\S)Quantifier.anyTimes: Matches 0 or more times (*)Quantifier.atLeastOne: Matches 1 or more times (+)Quantifier.atMostOne: Matches 0 or 1 time (?)Quantifier.exactly(n): Matches exactly n times ({n})Quantifier.atLeast(n): Matches at least n times ({n,})Quantifier.inRange(n..m): Matches between n and m times ({n,m})atLeastOneLazy, atLeastLazy(n), inRangeLazy(n..m)
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
A Kotlin Multiplatform library that provides a DSL for writing regular expressions in a more readable and maintainable way.
implementation("io.github.stream29:regexdsl:0.0.1")See at examples.ipynb
buildRegex { ... }: Creates a Regex object using the DSLbuildRegexString { ... }: Returns the string representation of the regex patternmatch(string): Matches a literal string (automatically escaped)match(char): Matches a literal character (automatically escaped)match(regexElement): Matches a regex element (e.g., digitChar, wordChar)matchCharacterSet { ... }: Matches a character set (e.g., [abc])matchNegatedCharacterSet { ... }: Matches a negated character set (e.g., [^abc])matchStringBegin(): Matches the beginning of the string (^)matchStringEnd(): Matches the end of the string ($)matchWordBoundary(): Matches a word boundary (\b)matchNonWordBoundary(): Matches a non-word boundary (\B)matchIndexedGroup { ... }: Creates a capturing group ((...))matchNamedGroup(name) { ... }: Creates a named capturing group ((?<name>...))matchUncapturedGroup { ... }: Creates a non-capturing group ((?:...))lookahead { ... }: Creates a positive lookahead assertion ((?=...))lookaheadNegative { ... }: Creates a negative lookahead assertion ((?!...))lookbehind { ... }: Creates a positive lookbehind assertion ((?<=...))lookbehindNegative { ... }: Creates a negative lookbehind assertion ((?<!...))insertOr(): Inserts an alternation operator (|)anyChar: Matches any character (.)digitChar: Matches a digit character (\d)nonDigitChar: Matches a non-digit character (\D)wordChar: Matches a word character (\w)nonWordChar: Matches a non-word character (\W)spaceChar: Matches a whitespace character (\s)nonSpaceChar: Matches a non-whitespace character (\S)Quantifier.anyTimes: Matches 0 or more times (*)Quantifier.atLeastOne: Matches 1 or more times (+)Quantifier.atMostOne: Matches 0 or 1 time (?)Quantifier.exactly(n): Matches exactly n times ({n})Quantifier.atLeast(n): Matches at least n times ({n,})Quantifier.inRange(n..m): Matches between n and m times ({n,m})atLeastOneLazy, atLeastLazy(n), inRangeLazy(n..m)
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.