Mods
Resource Packs
Data Packs
Modpacks
Shaders
Plugins
Mods Resource Packs Data Packs Plugins Shaders Modpacks
Sign in
ModsPluginsData PacksShadersResource PacksModpacks
Sign in
Settings
Regex Library Datapack

Regex Library Datapack

A datapack library that provides a way to match substrings using regular expressions.

506
10
Library
Utility
AboutGalleryChangelogVersions

This library requires Moxlib to function.

GMDU Regex Library

by Gears and Moxvallix.

Overview

This library provides a simple regular expression parser, working entirely in mcfunction.

Current Features and Metacharacters

Character Example Description
[] [abc] Character set
[^] [^abc] Inverted character set
[x-y] [A-Z] Character range
() (ab) Group
. . Wildcard
| (a|b) Or
^ ^abc Beginning of string
$ xyz$ End of string
? ab? Zero or one of the preceding token
* ab* Zero or more of the preceding token
+ ab+ One or more of the preceding token
\ \+ Escape following character

If you need help creating your regex pattern, we recommend using RegExr.

Not all features from RegExr are supported in our library, see table above.

Getting Started

This library uses a simple api. The string to match is given in target, and the regex to match with is set in pattern. These are set in the storage, regex:api/match

To run the match, run function regex:api/match.

Example

data modify storage regex:api/match target set value "Hello, World!"
data modify storage regex:api/match pattern set value "[A-Za-z]+"
function regex:api/match
{
  success: 1b,
  output: ["H","e","l","l","o"]
}

90% of ad revenue goes to creators

Support creators and Modrinth ad-free with Modrinth+

Compatibility

Minecraft: Java Edition

1.21
1.20.x
1.19.4

Platforms

Data Pack

Supported environments

Server-side
Client and server (optional)

Links

Report issues View source Join Discord server

Creators

GearsDatapacks
GearsDatapacks Co-Owner

Details

Licensed LGPL-3.0-or-later
Published 2 years ago
Updated last year

Modrinth is open source.

main@aaf125c

© Rinth, Inc.

Company

TermsPrivacyRulesCareers

Resources

SupportBlogDocsStatus

Interact

Discord X (Twitter) Mastodon Crowdin
Get Modrinth App Settings
NOT AN OFFICIAL MINECRAFT SERVICE. NOT APPROVED BY OR ASSOCIATED WITH MOJANG OR MICROSOFT.