rx

package
v0.0.0-...-af83795 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package rx 는 .NET 호환 정규식 엔진(regexp2)을 감싸 GitVersion 의 정규식 동작을 충실히 재현한다. 원본 GitVersion 은 .NET regex 를 쓰고, 설정/머지 포맷의 named capture `(?<name>...)` 와 backtracking 의미를 그대로 따른다. Go 표준 regexp(RE2) 대신 regexp2 를 사용해 .NET 과 동일한 매칭 결과를 얻는다.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsValid

func IsValid(pattern string) bool

IsValid 는 컴파일 가능한지만 확인한다.

Types

type Match

type Match struct {
	// contains filtered or unexported fields
}

Match 는 단일 매칭 결과 래퍼.

func (*Match) Group

func (m *Match) Group(idx int) (string, bool)

Group 은 인덱스 그룹 값과 참여 여부를 반환한다.

func (*Match) Named

func (m *Match) Named(name string) (string, bool)

Named 는 named capture 그룹의 값과 "참여 여부"를 반환한다. .NET 처럼 미참여 그룹은 (false) 로 구분된다(빈 캡처와 미참여를 구분).

func (*Match) NamedGroups

func (m *Match) NamedGroups() map[string]string

NamedGroups 는 참여한 named capture 그룹(이름->값)을 반환한다. 숫자 이름(무명 그룹)은 제외한다.

func (*Match) Whole

func (m *Match) Whole() string

Whole 은 전체 매칭 문자열을 반환한다.

type Regexp

type Regexp struct {
	// contains filtered or unexported fields
}

Regexp 는 regexp2.Regexp 래퍼.

func Compile

func Compile(pattern string) (*Regexp, error)

Compile 은 .NET 문법 정규식을 컴파일한다.

func CompileCached

func CompileCached(pattern string) (*Regexp, error)

CompileCached 는 컴파일 결과를 캐시한다.

func MustCompile

func MustCompile(pattern string) *Regexp

MustCompile 은 컴파일 실패 시 panic. 내장 상수 패턴 전용.

func (*Regexp) Find

func (r *Regexp) Find(s string) (*Match, bool)

Find 는 첫 매칭을 반환한다. 매칭이 없으면 (nil, false).

func (*Regexp) MatchString

func (r *Regexp) MatchString(s string) bool

MatchString 은 어디서든 매칭되면 true(에러 시 false).

func (*Regexp) ReplaceAll

func (r *Regexp) ReplaceAll(s, repl string) string

ReplaceAll 은 모든 매칭을 repl 로 치환한다($ 치환 구문 적용).

func (*Regexp) ReplaceAllFunc

func (r *Regexp) ReplaceAllFunc(s string, eval func(*Match) string) string

ReplaceAllFunc 은 모든 매칭을 evaluator 결과로 치환한다.

func (*Regexp) ReplaceFirst

func (r *Regexp) ReplaceFirst(s, repl string) string

ReplaceFirst 는 첫 매칭만 repl 로 치환한다(원본 .NET Regex.Replace(count=1)).

Jump to

Keyboard shortcuts

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