Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Vladimir Barsukov
zGo
Commits
f4971a0d
Commit
f4971a0d
authored
Dec 25, 2023
by
Vladimir Barsukov
Browse files
zre
parent
5a331752
Changes
1
Hide whitespace changes
Inline
Side-by-side
zre/zre.go
0 → 100644
View file @
f4971a0d
package
zre
import
(
"regexp"
)
var
cache
map
[
string
]
*
regexp
.
Regexp
func
init
()
{
cache
=
make
(
map
[
string
]
*
regexp
.
Regexp
)
}
func
New
(
s
string
)
*
regexp
.
Regexp
{
if
r
,
ok
:=
cache
[
s
];
ok
{
return
r
}
cache
[
s
]
=
regexp
.
MustCompile
(
s
)
return
cache
[
s
]
}
func
Replace
(
expr
string
,
s
,
rep
string
)
string
{
return
New
(
expr
)
.
ReplaceAllString
(
s
,
rep
)
}
func
Match
(
expr
,
s
string
)
bool
{
return
New
(
expr
)
.
MatchString
(
s
)
}
func
FindAll
(
expr
,
s
string
,
n
int
)
[]
string
{
return
New
(
expr
)
.
FindAllString
(
s
,
n
)
}
func
Find
(
expr
,
s
string
)
string
{
return
New
(
expr
)
.
FindString
(
s
)
}
func
FindSubmatch
(
expr
,
s
string
)
[]
string
{
return
New
(
expr
)
.
FindStringSubmatch
(
s
)
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment