Help us shape the future of Go! Take the 2026 Go Developer Survey

goblma

package module
v0.0.0-...-46f5cf3 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2019 License: MIT Imports: 2 Imported by: 1

README

Go balanced match

This is a go implementation of balanced-match

Usage
package main

import (
	"github.com/kujtimiihoxha/go-balanced-match"
	"fmt"
	"regexp"
)

func main() {
	v:= goblma.Balanced("{","}","pre{in{nested}}post")
	fmt.Println(v) //=> { Start:3, End:14, Pre:"pre", Body:"in{nested}" Post:"post"}

	v= goblma.Balanced("{","}","pre{first}between{second}post")
	fmt.Println(v) //=> { Start:3, End:9, Pre:"pre", Body:"first" Post:"between{second}post"}

	//Regex example
	regStart := regexp.MustCompile(`\s+\{\s+`)
	regEnd := regexp.MustCompile(`\s+\}\s+`)
	v= goblma.Balanced(regStart,regEnd,"pre  {   in{nest}   }  post")
	fmt.Println(v) //=> { Start:3, End:17, Pre:"pre", Body:"in{nested}" Post:"post"}


}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BalancedResult

type BalancedResult struct {
	Start int
	End   int
	Pre   string
	Body  string
	Post  string
}

func Balanced

func Balanced(a interface{}, b interface{}, str string) *BalancedResult

func Range

func Range(a []byte, b []byte, str string) *BalancedResult

Jump to

Keyboard shortcuts

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