我在 Jira 实例中设置了一些自动化功能,以捕获和删除在通过电子邮件将票证发送到 Jira 时自动生成的外部发件人表。我大部分时间都在工作,但有一个小而令人费解的部分在整个事情中引发了一把扳手。我可以删除 99% 的表格,但如果我将剩余的 2 个字符包含在代码中,它们将破坏整个删除过程。
这是有效的:
{{issue.description.replaceAll("\|\{color:#ff3333\} \*EXTERNAL SENDER:\*\{color\} Do not click any links or open any attachments unless you trust the sender and know the content is safe.\|\n\|", "")}}
请注意,管道指示表的一段的开始和结束。该表有 2 行。有效的(上图)是删除所有表格,除了表格第二行的中间和末尾。
这是不起作用的:
{{issue.description.replaceAll("\|\{color:#ff3333\} \*EXTERNAL SENDER:\*\{color\} Do not click any links or open any attachments unless you trust the sender and know the content is safe.\|\n\| \|", "")}}
此示例在末尾添加了一个空格字符和一个管道(行结束)字符。实际上,这确实与表的复制/粘贴完全匹配,并且应该完美地翻译并完成从工单描述中删除外部发件人表的最后 1%。有效的代码只能删除除“|”之外的所有内容 部分在最后。一旦我添加了最后一部分,代码就会中断并且不会删除外部发件人表的一位。最后,我尝试了对代码的多种变体,包括:
-----
safe.\|\n\|
(has a space at the end)
Seems to not catch anything and leaves the whole External Sender table up.
-----
safe.\|\n\| \|
(space in middle before closing pipe)
Seems to not catch anything and leaves the whole External Sender table up.
-----
safe.\|\n\|\|
(no spaces, double pipe in a row after new line)
Seems to not catch anything and leaves the whole External Sender table up.
-----
safe.\|\n\|\u0020\|
(escaping space character)
Seems to not catch anything and leaves the whole External Sender table up.
-----
safe.\|\n\|\t\|
(treats space like a tab)
Seems to not catch anything and leaves the whole External Sender table up.
-----
有什么我在这里遗漏的东西可以解释为什么只有“\|” 最后部分替换 JSON 代码会导致代码完全错过表格吗?