|
|
@@ -0,0 +1,52 @@
|
|
|
+#nop 两个字符串参数,其中一个比另一个多包含了一个子串,本函数可返回该子串(即任务信息);
|
|
|
+#function {diff} {
|
|
|
+ #local str1 {%1};
|
|
|
+ #local str2 {%2};
|
|
|
+
|
|
|
+ #list str1 {tokenize} {$str1};
|
|
|
+ #list str2 {tokenize} {$str2};
|
|
|
+
|
|
|
+ #local size1 {&str1[]};
|
|
|
+ #local size2 {&str2[]};
|
|
|
+
|
|
|
+ #if { $size1 < $size2 } {
|
|
|
+ #local tmp {$str1};
|
|
|
+ #local str1 {$str2};
|
|
|
+ #local str2 {$tmp};
|
|
|
+ #local tmp {$size1};
|
|
|
+ #local size1 {$size2};
|
|
|
+ #local size2 {$tmp};
|
|
|
+ };
|
|
|
+
|
|
|
+ #local idx {};
|
|
|
+ #loop {1} {$size2} {idx} {
|
|
|
+ #local ch1 {$str1[$idx]};
|
|
|
+ #local ch2 {$str2[$idx]};
|
|
|
+ #if { "$ch1" != "$ch2" } {
|
|
|
+ #break;
|
|
|
+ };
|
|
|
+ };
|
|
|
+
|
|
|
+ #local begin {$idx};
|
|
|
+ #local end {};
|
|
|
+ #math end {$size1 - $size2 + $begin - 1};
|
|
|
+ #local diff {};
|
|
|
+ #loop {$begin} {$end} {idx} {
|
|
|
+ #local ch {$str1[$idx]};
|
|
|
+ #cat diff {$ch};
|
|
|
+ };
|
|
|
+
|
|
|
+ #return {$diff};
|
|
|
+};
|
|
|
+
|
|
|
+/*
|
|
|
+#alias {diff.test} {
|
|
|
+ #local str1 {洞中无丝毫光亮,脚华山的练功房下平整,便似走在石板路上一般。};
|
|
|
+ #local str2 {洞中无丝毫光亮,脚下平整,便似走在石板路上一般。};
|
|
|
+ #echo {STR1: $str1};
|
|
|
+ #echo {STR2: $str2};
|
|
|
+ #local diff {@diff{{$str1};{$str2}}};
|
|
|
+ #nop 会得到「华山的练功房」
|
|
|
+ #echo {DIFF: $diff};
|
|
|
+};
|
|
|
+*/
|