Forum Discussion
rraghvani
Champion Level 3
Refer to Logical AND (&&) and the other operators shown for JavaScript.
tvklovesu
2 years agoFrequent Contributor
Thanks for your input. Actually I wrote my own function to test those three operators as below. Please let me know if you think I can still simplify this. Also I need to test one more condition that is when searched with text along with ~ (Ex. Muhamed~ returns results including Muhammad, Mohamed, Muhammed, etc.). Is there any way that I can test if the string is similar to what I searched for. I tried looking in to the reqular expressions but can't find it.
function VerifyString(colString, operatorType){
wordCount = stringArry.length-1
result = []
if (operatorType=='and'){
for (j=0;j<=wordCount; j++){
if (aqString.StrMatches(stringArry[j], colString) ==true){
result.push(true)
}else{
result.push(false)
}
if (result.indexOf(false)==0){
Log.Error("The text in the column "+colString+" doesn't contain the word "+stringArry[j])
}
}
}
if (operatorType=='or'){
for (j=0;j<=wordCount; j++){
if (aqString.StrMatches(stringArry[j], colString) ==true){
result.push(true)
}else{
result.push(false)
}
}
if (result.indexOf(true)==-1){
Log.Error("The text in the column doesn't contains any of the search words "+colString)
}
}
if (operatorType=='not'){
for (j=0;j<=wordCount; j++){
if (aqString.StrMatches(stringArry[j], colString) ==true){
result.push(true)
}else{
result.push(false)
}
}
//Log.Message(result.indexOf(true) +", "+result[wordCount])
if (result.indexOf(true)==-1 || result[wordCount] != false){
Log.Error("The text in the column doesn't match with the search string "+colString)
}
}
}
Related Content
- 5 years ago
- 4 years ago
- 8 years ago