FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
librime-lua-script/lua/tools/meta_string.lua at main · shewer/librime-lua-script · GitHub
shewer
librime-lua-script
Repository navigation
Code
Issues
4
(4)
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
librime-lua-script
/
lua
/
tools
/
meta_string.lua
Copy path
More file actions
More file actions
Latest commit
History
History
History
executable file
·
55 lines (48 loc) · 1.12 KB
Breadcrumbs
librime-lua-script
/
lua
/
tools
/
meta_string.lua
Copy path
File metadata and controls
executable file
·
55 lines (48 loc) · 1.12 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!
/usr/bin/env lua
--
--
meta_string.lua
--
Copyright (C) 2020 Shewer Lu <shewer@gmail.com>
--
--
Distributed under terms of the MIT license.
--
local
Class
=
require
'
muti_reverse
'
local
Filter
=
Class
.
Filter
setmetatable
(
string
,{
__index
=
table
})
local
metatable_string
=
metatable
()
function
metatable_string
:
filter
(
filter
,...)
local
_filter
=
filter
or
FILTER
if
_filter
then
local
_type
=
type
(
_filter
)
if
_type
==
"
function
"
then
return
_filter
(
self
,
...
)
elseif
_type
==
"
table
"
or
_filter
:
is_a
(
Filter
)
then
return
_filter
:
filter
(
self
,
...
)
end
end
return
str
,
str
end
function
metatable_string
.
split
(
str
,
sp
,
sp1
)
if
type
(
sp
)
==
"
string
"
then
if
sp
:
len
()
==
0
then
sp
=
"
([%z
\1
-
\127\194
-
\244
][
\128
-
\191
]*)
"
elseif
sp
:
len
()
>
1
then
sp1
=
sp1
or
"
^
"
_
,
str
=
pcall
(
string.gsub
,
str
,
sp
,
sp1
)
sp
=
"
[^
"
..
sp1
..
"
]*
"
else
if
sp
==
"
%
"
then
sp
=
"
%%
"
end
sp
=
"
[^
"
..
sp
..
"
]*
"
end
else
sp
=
"
[^
"
..
"
"
..
"
]+
"
end
local
tab
=
setmetatable
( {} , {
__index
=
table
} )
flag
,
res
=
pcall
(
string.gmatch
,
str
,
sp
)
for
v
in
res
do
tab
:
insert
(
v
)
end
return
tab
end
return
metatable_string
Back
|
FazBrowse Home
|
New Git URL