简体   繁体   English

如何放心使用正则表达式

[英]How to use the regex in rest assured

Like i have to validate in name it should accept only the alphabets value if any numeric value or special char is entered than in response it should give an error.就像我必须验证名称一样,如果输入任何数值或特殊字符,它应该只接受字母值,而不是响应它应该给出错误。

Note i want to use regex on every key.注意我想在每个键上使用正则表达式。

You can traverse through the response and get the element and store it in a variable of String type.您可以遍历响应并获取元素并将其存储在 String 类型的变量中。
Then you can use contains method to check if any special character or numeric value which you want to check is present or not.eg of contain method然后您可以使用 contains 方法来检查您要检查的任何特殊字符或数值是否存在。例如,包含方法

text.contains("[0-9]+")

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

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