Download Regex Library Datapack — Minecraft Mods — MetaMods
Regex Library Datapack

Regex Library Datapack

Active

Downloads

0

Last update

1 year ago

Versions

23w03a — 1.21
Server
Libraries
Utils

GMDU Regex Library

This library provides a full-fledged regular expressions parser functioning exclusively in mcfunction.

Features and Operators

Current version implements main regular expression metacharacters:

  • [] - character set matching
  • [^] - character set exclusion
  • [x-y] - character range
  • () - expression grouping
  • . - any character
  • | - OR operator
  • ^ - start of string
  • $ - end of string
  • ? - zero or one occurrence
  • * - zero or more occurrences
  • + - one or more occurrences
  • \ - character escaping

Library Usage

Required steps: 1) set target string in target and regex pattern in pattern via data storage regex:api/match, 2) execute function regex:api/match.

Implementation 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"]
}

Note: Requires Moxlib to function properly.

Created by Gears and Moxvallix.

Project members
GearsDatapacks

GearsDatapacks

Developer

Created: 15 Feb 2023

ID: 10998