简体   繁体   English

空手道 API - 数字 [0-9] 或 null 的常规 exp

[英]Karate API - Regular exp for numbers[0-9] or null

I am trying this below regular exp in karate api automation to check the field value is numeric[0-9] or null value.我在空手道 api 自动化中尝试低于常规 exp 以检查字段值是数字 [0-9] 或 null 值。 but its not giving correct results.但它没有给出正确的结果。 Can anyone help on this?有人可以帮忙吗?

The regular exp is '#regex (?:[0-9]{1}|null)'正则表达式是'#regex (?:[0-9]{1}|null)'

Example: From the below JSON sometimes sisters/brothers response will be integers or null.示例:从下面的 JSON 有时姐妹/兄弟的响应将是整数或 null。 So I want to validate with regex to ensure it has integers/null data.所以我想用正则表达式验证以确保它有整数/空数据。

"info": { "Name": Tomas, "Age": 29, "Sisters": 1, "Brothers": null, “信息”:{“姓名”:托马斯,“年龄”:29,“姐妹”:1,“兄弟”:null,

    }

I found the answer, the below reg exp is working我找到了答案,下面的 reg exp 正在工作

  • match response.info.sisters == '##regex [0-9]{1}'匹配 response.info.sisters == '##regex [0-9]{1}'

thanks谢谢

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM