Rgx
a tiny regex engine written in go
Install / Use
/learn @rhaeguard/RgxREADME
rgx
A very simple regex engine written in go. This library is experimental, use it at your own risk!
read the article.
to add the dependency:
go get github.com/rhaeguard/rgx
how to use:
import "github.com/rhaeguard/rgx"
pattern, err := rgx.Compile(regexString)
if err != nil {
// error handling
}
results := pattern.FindMatches(content)
if results.Matches {
groupMatchString := results.Groups["group-name"]
}
todo
- [x]
^beginning of the string - [x]
$end of the string - [x]
.any single character/wildcard - [x] bracket notation
- [x]
[ ]bracket notation/ranges - [x]
[^ ]bracket negation notation - [x] better handling of the bracket expressions: e.g.,
[ab-exy12] - [x] special characters in the bracket
- [x] support escape character
- [x]
- [x] quantifiers
- [x]
*none or more times - [x]
+one or more times - [x]
?optional - [x]
{m,n}more than or equal tomand less than equal tontimes
- [x]
- [x] capturing group
- [x]
( )capturing group or subexpression - [x]
\nbackreference, e.g,(dog)\1wherenis in[0, 9] - [x]
\k<name>named backreference, e.g,(?<animal>dog)\k<animal> - [x] extracting the string that matches with the regex
- [x]
- [x]
\escape character- [x] support special characters - context dependant
- [x] better error handling in the API
- [x] ability to work on multi-line strings (tested on Alice in Wonderland text corpus)
- [x]
.should not match the newline -\n - [x]
$should match the newline -\n - [x] multiple full matches
- [x]
notes
\escape turns any next character into a literal, no special combinations such as\dfor digits,\bfor backspace, etc. are allowed- numeric groups
\nonly support single digit references, so\10will be interpreted as the first capture group followed by a literal0
credits
Related Skills
node-connect
351.4kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
xurl
351.4kA CLI tool for making authenticated requests to the X (Twitter) API. Use this skill when you need to post tweets, reply, quote, search, read posts, manage followers, send DMs, upload media, or interact with any X API v2 endpoint.
frontend-design
110.7kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
351.4kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
