I have a string as
str= "value 1 then perform certain action"
I need a regular expression that will make sure value and perform are present in string without being repeated.
no need regular expression for this simple task. use this code
str= "value 1 then perform certain action"
var a = str.match("value") || []
var b = str.match("perform") || []
if(a.length == 1 && b.length == 1){
console.log("true")
}else{
console.log("false")
}
您可以按如下方式设置模式:
pattern: "value (.*) perform (.*)"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.