rassemble

package module
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 8, 2024 License: MIT Imports: 4 Imported by: 8

README

rassemble-go

CI Status Go Report Card MIT License release pkg.go.dev

Go implementation of Regexp::Assemble

This is a Go language package for joining regular expressions into a regular expression which matches all strings that any of the arguments matches.

package main

import (
	"fmt"
	"log"

	"github.com/itchyny/rassemble-go"
)

func main() {
	xs, err := rassemble.Join([]string{"abc", "ab", "acbd", "abe"})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(xs) // a(?:b[ce]?|cbd)
}

A command line tool is also provided.

 % go install github.com/itchyny/rassemble-go/cmd/rassemble@latest
 % rassemble abcd abd acd ad
ab?c?d
 % rassemble $(head -n30 /usr/share/dict/words)
A(?:a(?:ni|r(?:on(?:i(?:c(?:al)?|t(?:e|ic)))?|u))|b(?:ab(?:deh|ua))?)?|a(?:a(?:l(?:ii)?|m|rd(?:vark|wolf))?|ba(?:c(?:a(?:te|y)?|i(?:nat(?:e|ion)|s(?:cus|t))|k|tinal(?:ly)?)?)?)?

Bug Tracker

Report bug at Issues・itchyny/rassemble-go - GitHub.

Author

itchyny (https://github.com/itchyny)

License

This software is released under the MIT License, see LICENSE.

Documentation

Overview

Package rassemble provides a method to assemble regular expressions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Join

func Join(patterns []string) (string, error)

Join patterns to build a regexp pattern.

Types

This section is empty.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL