12-06-2022, 01:20 AM
I thought of the following method, but the final replacement result is wrong, why?
Macro Macro5
Macro Macro5
out
_s=
;mes1 :sub.Sub1
;mes2 :sub.Sub2
;
;#sub Sub1 m
;_s="hello 1"
;mes _s
;
;#sub Sub2 m
;_s="hello 2"
;mes _s
ARRAY(str) as
findrx(_s "(?m)^#sub Sub(\d+) m(?:(?!^#sub Sub\d+ m)[\s\S])+" 0 4 as)
str k v kv
for _i 0 as.len
,k=as[1 _i]
,v=as[0 _i].trim
,v.findreplace("[]" "┃")
,kv.formata("%s=%s[]" k v)
out kv
IStringMap m._create
m.AddList(kv "=")
v=m.Get("1")
if(v)
,out v ;;The output is correct
,out v.findreplace("┃" "[]") ;;The output is wrong, why?
else
,out "not found"