Copy link to clipboard
Copied
Hi, I have field "Text1" I want to check if string from that field contains palindrome and write "Yes" or "No" in another field.
Is that possible?
You can use this as calculation script of yes/no field:
var str = this.getField("Text1").valueAsString;
var pal = str.replace(/[^\w]/g, "");
var x = pal.split('').reverse().join('');
if(str == "") event.value = "";
else if(x === pal) event.value = "Yes";
else event.value = "No";
Copy link to clipboard
Copied
Hi, I am not sure that can be done without checking against a list stored in the language you want, especially if all the letters of the word are entered in the same field instead of 1 letter per field.
Copy link to clipboard
Copied
You can use this as calculation script of yes/no field:
var str = this.getField("Text1").valueAsString;
var pal = str.replace(/[^\w]/g, "");
var x = pal.split('').reverse().join('');
if(str == "") event.value = "";
else if(x === pal) event.value = "Yes";
else event.value = "No";
Copy link to clipboard
Copied
How does you check the sense of the words?
Copy link to clipboard
Copied
You can only check a subset of possible words.
Copy link to clipboard
Copied
UPDATE: I made a mistake in my post, I meant to check if string is palindrome not if it contains one.
Thanks Nesa for your script Il try it later and get back to you.