我需要构建一个字符串并将其传递给外部程序。我需要使用 Eval Insert 函数来构建字符串,但该字符串还需要包含一个正则表达式,其中包含 ^ 字符。
我无法让 JMP(版本 19.1.4)在 Eval Insert 调用中忽略该字符。以下是一个示例:
Str_To_Eval = "Insert_Str";
str = "This is a String containing ^Str_To_Eval^ and it also contains this regex : ^(?!.*_).*";
eval insert(str)
此操作失败,并出现以下错误:
意外的“?”。或许缺少一个“)”。
第 1 行第 37 列:(?!.*_).*►
在 ^ 字符前加上 \! 并无帮助。将其包裹在 \[ ..]\ 中也无济于事。
我可以这样解决:
Str_To_Eval = "Insert_Str";
RegExFragment = "^";
str = "This is a String containing ^Str_To_Eval^ and it also contains this regex : ^RegExFragment^(?!.*_).*";
eval insert(str);
这样就能得到我想要的结果。
我想知道是否有其他方法可以转义 ^ 字符,以便 Eval Insert() 函数忽略它?
请使用除^以外的字符。我通常使用¤。
Names Default To Here(1);
Eval Insert("Today is ¤As Date(Today())¤", "¤");
执行插入(字符串, , ,<< )

谢谢!真不敢相信我用了 JMP 快二十年了,竟然一直没发现 Eval Insert() 函数有个可选参数可以指定分隔符!看来读手册还是有用的 