Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 28bbd12

Browse files
maj_20240723-01:13
1 parent 64ddcaa commit 28bbd12

File tree

6 files changed

+535
-3
lines changed

6 files changed

+535
-3
lines changed

‎MenuDEV.sh‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,11 @@ do
7474
f_dsplyPos 10 20 $faGras$fcRouge'12.'; f_dsplyPos 10 24 $faGras$fcGreen 'exCallpgm'
7575
f_dsplyPos 11 20 $faGras$fcRouge'13.'; f_dsplyPos 11 24 $faGras$fcGreen 'Exemple'
7676
f_dsplyPos 12 20 $faGras$fcRouge'14.'; f_dsplyPos 12 24 $faGras$fcGreen 'Zregex'
77-
f_dsplyPos 13 24 $faGras$fcJaune'----------------------------------------'
77+
f_dsplyPos 13 20 $faGras$fcRouge'15.'; f_dsplyPos 13 24 $faGras$fcGreen'testmvzr'
7878

79-
f_dsplyPos 14 20 $faGras$fcRouge'33.'; f_dsplyPos 14 24 $faGras$fcGreen 'Debug codelldb'
79+
f_dsplyPos 14 24 $faGras$fcJaune '----------------------------------------'
80+
81+
f_dsplyPos 15 20 $faGras$fcRouge'33.'; f_dsplyPos 15 24 $faGras$fcGreen 'Debug codelldb'
8082

8183
f_dsplyPos 16 20 $faGras$fcRouge'44.'; f_dsplyPos 16 24 $faGras$fcCyan 'enScript Printer'
8284

@@ -138,6 +140,12 @@ do
138140
14)
139141
/home/soleil/.Terminal/dispatch.sh $envZIG $LIBPROJECT "Zregex"
140142
;;
143+
144+
145+
15)
146+
/home/soleil/.Terminal/dispatch.sh $envZIG $LIBPROJECT "testmvzr"
147+
;;
148+
141149
#debug
142150
33)
143151
/home/soleil/.Terminal/debugZig.sh $PROJECT

‎README.md‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
# ZIG_REGEX
22
PCRE2-POSIX
33

4-
AND TEST FLUENT
4+
55

66

77
Using "regex" from the new PCRE2-Posix standard<br>
88

9+
https://github.com/mnemnion/mvzr new regex form ZIG
10+
911
example:<br>
1012

1113
Pay attention to the flag that is incumbent on you.<br>
@@ -138,3 +140,7 @@ buf = [_]u8{0} ** 3;
138140
* •upgrade 2024年07月01日.<BR />
139141
&nbsp;&nbsp;&nbsp;&larr;&nbsp;Test Fluent and PCRE "C" Zregex<BR />
140142

143+
144+
* •upgrade 2024年07月22日.<BR />
145+
&nbsp;&nbsp;&nbsp;&larr;&nbsp;Test MVZR and PCRE "C" Zregex<BR />
146+

‎src-zig/buildcfluent.zig‎

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// version 0.12. dev
2+
3+
const std = @import("std");
4+
5+
pub fn build(b: *std.Build) void {
6+
// Standard release options allow the person running `zig build` to select
7+
// between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall.
8+
const target = b.standardTargetOptions(.{});
9+
const optimize = b.standardOptimizeOption(.{});
10+
11+
// zig-src source projet
12+
// zig-src/deps curs/ form / outils ....
13+
// src_c source c/c++
14+
15+
16+
17+
// Definition of dependencies
18+
19+
const match = b.createModule(.{
20+
.root_source_file= b.path("./deps/curse/match.zig"),
21+
});
22+
match.addIncludePath( b.path("./lib/"));
23+
24+
25+
const fluent = b.createModule(.{
26+
.root_source_file= b.path("./deps/curse/fluent.zig"),
27+
});
28+
29+
// Building the executable
30+
const Prog = b.addExecutable(.{
31+
.name = "cfluent",
32+
.root_source_file = b.path("./cfluent.zig" ),
33+
.target = target,
34+
.optimize = optimize,
35+
});
36+
37+
38+
Prog.linkLibC();
39+
Prog.addObjectFile(.{.cwd_relative = "/usr/lib/libpcre2-posix.so"});
40+
Prog.root_module.addImport("match" , match);
41+
Prog.root_module.addImport("fluent" , fluent);
42+
43+
b.installArtifact(Prog);
44+
45+
46+
47+
}

‎src-zig/buildtestmvzr.zig‎

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// version 0.12. dev
2+
3+
const std = @import("std");
4+
5+
pub fn build(b: *std.Build) void {
6+
// Standard release options allow the person running `zig build` to select
7+
// between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall.
8+
const target = b.standardTargetOptions(.{});
9+
const optimize = b.standardOptimizeOption(.{});
10+
11+
// zig-src source projet
12+
// zig-src/deps curs/ form / outils ....
13+
// src_c source c/c++
14+
15+
16+
17+
// Definition of dependencies
18+
19+
const match = b.createModule(.{
20+
.root_source_file= b.path("./deps/curse/match.zig"),
21+
});
22+
match.addIncludePath( b.path("./lib/"));
23+
24+
25+
// Building the executable
26+
const Prog = b.addExecutable(.{
27+
.name = "testmvzr",
28+
.root_source_file = b.path("./testmvzr.zig"),
29+
.target = target,
30+
.optimize = optimize,
31+
});
32+
33+
// Resolve the 'library' dependency.
34+
const library_dep = b.dependency("library", .{});
35+
36+
Prog.linkLibC();
37+
Prog.addObjectFile(.{.cwd_relative = "/usr/lib/libpcre2-posix.so"});
38+
Prog.root_module.addImport("match" , match);
39+
Prog.root_module.addImport("mvzr", library_dep.module("mvzr"));
40+
41+
b.installArtifact(Prog);
42+
43+
44+
45+
}

‎src-zig/cfluent.zig‎

Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
const std = @import("std");
2+
3+
// tools regex
4+
const creg = @import("match");
5+
// tools fluent regex
6+
const freg = @import("fluent");
7+
8+
const allocatorPrint = std.heap.page_allocator;
9+
10+
fn isMatch(vbuf : [] const u8 , comptime vmatch : [] const u8) bool {
11+
12+
var rep = freg.match(vmatch,vbuf) ;
13+
14+
while (rep.next()) |value| {
15+
16+
// std.debug.print("Fluent Macth {s}: {s} \r\n",.{vbuf, value}) ;
17+
18+
if ( std.mem.eql(u8, vbuf, value) ) return true else return false ;
19+
}
20+
21+
return false;
22+
}
23+
24+
25+
pub fn main() !void {
26+
27+
28+
29+
30+
std.debug.print("-----------------------\r\n",.{});
31+
var buf : [] const u8 = "P1";
32+
// contrôl "P1"
33+
std.debug.print("Macth {s}: {} \r\n",.{buf,creg.isMatch(buf,"^[A-Z]{1,1}[a-zA-Z0-9]{0,}$")}) ;
34+
35+
std.debug.print("fluent {s} :{} \r\n",.{buf,
36+
isMatch(buf,"^[A-Z]{1}[a-zA-Z0-9]")});
37+
38+
39+
40+
std.debug.print("-----------------------\r\n",.{});
41+
buf =undefined;
42+
buf = "p1";
43+
// contrôl "P1"
44+
std.debug.print("Macth {s}: {} \r\n",.{buf,creg.isMatch(buf,"^[A-Z]{1,1}[a-zA-Z0-9]{0,}$")}) ;
45+
46+
std.debug.print("fluent {s} :{} \r\n",.{buf,
47+
isMatch(buf,"[A-Z]{1}[a-zA-Z0-9]{1,2}") });
48+
49+
50+
std.debug.print("-----------------------\r\n",.{});
51+
buf =undefined;
52+
buf = "P";
53+
// contrôl obligatoire P and 1
54+
std.debug.print("Macth {s}: {} \r\n",.{buf,creg.isMatch(buf,"^[A-Z]{1,1}[a-zA-Z0-9]{1,}$")}) ;
55+
56+
std.debug.print("fluent {s} :{} \r\n",.{buf,
57+
isMatch(buf,"[A-Z]{1}[a-zA-Z0-9]{1,2}")
58+
});
59+
60+
61+
std.debug.print("-----------------------\r\n",.{});
62+
buf =undefined;
63+
buf = "P1abc";
64+
std.debug.print("Macth {s}: {} \r\n",.{buf,creg.isMatch(buf,"^[A-Z]{1,1}[a-zA-Z0-9]{0,}$")}) ;
65+
// Attenion length
66+
std.debug.print("fluent {s} :{} \r\n",.{buf,
67+
isMatch(buf,"[A-Z]{1}[a-zA-Z0-9]{1,5}")
68+
});
69+
70+
// not accept var
71+
// const allocRegex = std.heap.page_allocator;
72+
// const xx = std.fmt.allocPrint(allocRegex,"[A-Z]{1}[a-zA-Z0-9]{{1,{d}}}",.{buf.len}) catch unreachable;
73+
// std.debug.print("fluent:{} \r\n",.{isMatch(buf,xx)});
74+
75+
std.debug.print("-----------------------\r\n",.{});
76+
buf =undefined;
77+
buf = "P1@";
78+
// improper
79+
std.debug.print("Macth {s}: {} \r\n",.{buf,creg.isMatch(buf,"^[A-Z]{1,1}[a-zA-Z0-9]{0,}$")}) ;
80+
std.debug.print("fluent {s} :{} \r\n",.{buf,
81+
isMatch(buf,"[A-Z]{1}[a-zA-Z0-9]{1,3}")
82+
});
83+
84+
std.debug.print("-----------------------\r\n",.{});
85+
buf =undefined;
86+
buf = "@P1";
87+
// improper
88+
std.debug.print("Macth {s}: {} \r\n",.{buf,creg.isMatch(buf,"^[A-Z]{1,1}[a-zA-Z0-9]{0,}$")}) ;
89+
std.debug.print("fluent {s} :{} \r\n",.{buf,
90+
isMatch(buf,"[A-Z]{1}[a-zA-Z0-9]{1,3}")
91+
});
92+
93+
std.debug.print("-----------------------\r\n",.{});
94+
buf =undefined;
95+
buf = "1951-02-29";
96+
97+
// test date réel contrôl full
98+
std.debug.print("Macth {s} date iso{} \r\n",.{buf,creg.isMatch(
99+
buf,
100+
"^([0-9]{4}[-/]?((0[13-9]|1[012])[-/]?(0[1-9]|[12][0-9]|30)|(0[13578]|1[02])[-/]?31|02[-/]?(0[1-9]|1[0-9]|2[0-8]))|([0-9]{2}(([2468][048]|[02468][48])|[13579][26])|([13579][26]|[02468][048]|0[0-9]|1[0-6])00)[-/]?02[-/]?29)$")});
101+
102+
std.debug.print("fluent {s} date iso:{} \r\n",.{buf,
103+
isMatch(buf,"^([0-9]{4}[-/]?((0[13-9]|1[012])[-/]?(0[1-9]|[12][0-9]|30)|(0[13578]|1[02])[-/]?31|02[-/]?(0[1-9]|1[0-9]|2[0-8]))|([0-9]{2}(([2468][048]|[02468][48])|[13579][26])|([13579][26]|[02468][048]|0[0-9]|1[0-6])00)[-/]?02[-/]?29)$")
104+
});
105+
106+
107+
buf =undefined;
108+
buf = "1952年02月29日";
109+
std.debug.print("Macth {s} date iso{} \r\n",.{buf,creg.isMatch(
110+
buf,
111+
"^([0-9]{4}[-/]?((0[13-9]|1[012])[-/]?(0[1-9]|[12][0-9]|30)|(0[13578]|1[02])[-/]?31|02[-/]?(0[1-9]|1[0-9]|2[0-8]))|([0-9]{2}(([2468][048]|[02468][48])|[13579][26])|([13579][26]|[02468][048]|0[0-9]|1[0-6])00)[-/]?02[-/]?29)$")});
112+
113+
std.debug.print("fluent {s} :{} \r\n",.{buf,
114+
isMatch(buf,"^([0-9]{4}[-/]?((0[13-9]|1[012])[-/]?(0[1-9]|[12][0-9]|30)|(0[13578]|1[02])[-/]?31|02[-/]?(0[1-9]|1[0-9]|2[0-8]))|([0-9]{2}(([2468][048]|[02468][48])|[13579][26])|([13579][26]|[02468][048]|0[0-9]|1[0-6])00)[-/]?02[-/]?29)$")
115+
}); // gets lost in this clues |[3][0-1]{1,2}
116+
117+
118+
119+
120+
//oreilly editor book
121+
buf =undefined;
122+
buf = "myname.myfirstname@gmail.com";
123+
std.debug.print("Macth {s} mail: {} \r\n",.{buf,creg.isMatch(
124+
buf,
125+
"^[a-zA-Z0-9_!#$%&'*+/=?`{|}~^.-]+@[a-zA-Z0-9.-]+$")});
126+
127+
std.debug.print("fluent {s} mail :{} \r\n",.{buf,
128+
isMatch(buf,"[a-zA-Z0-9_!#$%&.-]+@[a-zA-Z0-9.-]+")
129+
});
130+
131+
132+
const width :usize = 5;
133+
const scal :usize = 2;
134+
buf =undefined;
135+
buf = "12345.02";
136+
// decimal unsigned scal > 0
137+
std.debug.print("Macth decimal unsigned {s} scal > 0 {} \r\n",.{buf,creg.isMatch(
138+
buf,
139+
std.fmt.allocPrint(allocatorPrint,
140+
"^[0-9]{s}1,{d}{s}[.][0-9]{s}{d}{s}$",.{"{",width,"}","{",scal,"}"}
141+
) catch unreachable)});
142+
143+
std.debug.print("fluent {s} :{} \r\n",.{buf,
144+
isMatch(buf,"^[0-9]{1,5}[.][0-9]{2}$")
145+
});
146+
147+
148+
149+
// norme rFC 2822 preceding 5322 which includes text in front,
150+
buf =undefined;
151+
buf = "jpl_myname.myfirstname@gmail.com";
152+
153+
std.debug.print("Macth Mail:{s} {} \r\n",.{buf,creg.isMatch(
154+
buf,
155+
"^[a-zA-Z0-9!#$%&'*+\\/=?^_`{|}~-]+(?:\\.[a-zA-Z0-9!#$%&'*+\\/=?^_`{|}~-]+)*@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$")});
156+
157+
158+
// var itr2 = freg.match("^[a-zA-Z0-9!#$%&'*+\\/=?^_`{|}~-]+(?:\\.[a-zA-Z0-9!#$%&'*+\\/=?^_`{|}~-]+)*@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$",buf);
159+
// while (itr2.next()) |str|{
160+
// std.debug.print("SHOULD NOT SEE THIS |{s}|\n", .{ str });}
161+
162+
163+
164+
}
165+

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /