Skip to content

kujtimiihoxha/go-balanced-match

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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


}

About

Go implementation of juliangruber/balanced-match

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages