空手道核心:为什么在为数组元素匹配正则表达式时不能使用双反斜杠转义? [英] karate-core: why double back-slash escaping is not working while matching regex for array elements?
本文介绍了空手道核心:为什么在为数组元素匹配正则表达式时不能使用双反斜杠转义?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
基于空手道文档:
请注意,正则表达式转义必须使用双反斜杠-例如:'
#regex a\\.dot
'将匹配'a.dot'
Note that regex escaping has to be done with a double back-slash - for e.g: '
#regex a\\.dot
' will match 'a.dot'
将数字与\\d+
匹配对于简单的字符串变量可以很好地工作:
matching numbers with \\d+
is working fine for simple string variables:
* def foo = '123'
* match foo == '#regex\\d+'
但不适用于字符串数组:
but it's not working for string arrays:
* def bar = ['123']
* match bar == '#[] #regex\\d+'
断言失败:路径:$ [0],实际值:'123',预期值:'#regexd +',原因:正则表达式匹配失败
assertion failed: path: $[0], actual: '123', expected: '#regexd+', reason: regex match failed
我想念什么吗?
推荐答案
是一个错误: https ://github.com/intuit/karate/issues/988
现在您可以将反斜杠加倍'#[] #regex\\\\d+'
For now you can double the backslashes '#[] #regex\\\\d+'
但这将在下一版本中修复.
But this will be fixed in the next version.
这篇关于空手道核心:为什么在为数组元素匹配正则表达式时不能使用双反斜杠转义?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文