legion-regex

Regular expression utilities for legionhjyu. Match, capture, replace, split, and validate strings with full regex support.

v1.0.1 MIT @legionhjyu Updated NaNy ago
Install
legion pkg install legion-regex

legion-regex

Regular expressions for legionhjyu.

Install

legion pkg install legion-regex

Usage

summon "legion-regex" release re

forge email_re <- re.compile("[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}")

blade re.test(email_re, "hello@example.com") { shout("Valid email!") }

forge matches <- re.findall(email_re, text) forge cleaned <- re.sub(re.compile("\\s+"), " ", messy_text)

Functions

FunctionDescription
re.compile(pattern)Compile a regex pattern
re.test(re, str)Returns true if match found
re.match(re, str)Returns first match object
re.findall(re, str)Returns list of all matches
re.sub(re, repl, str)Replace all matches
re.split(re, str)Split string by pattern
re.groups(match)Returns capture groups