I use the code below in iMacros to extract the first 10 words of a phrase. There are situations when it works 100%, but there are also other situations when some of the extracted words are called "undefined"
Does anyone know why this is happening? Or does anyone know a better option to extract a certain number of words from a phrase? First 10 or first 15 words, etc. etc
set !var0 eval("var s=\"{{!extract}}\"; s=s.split(\" \");s[0];")
set !var1 eval("var s=\"{{!extract}}\"; s=s.split(\" \");s[1];")
set !var2 eval("var s=\"{{!extract}}\"; s=s.split(\" \");s[2];")
set !var3 eval("var s=\"{{!extract}}\"; s=s.split(\" \");s[3];")
set !var4 eval("var s=\"{{!extract}}\"; s=s.split(\" \");s[4];")
set !var5 eval("var s=\"{{!extract}}\"; s=s.split(\" \");s[5];")
set !var6 eval("var s=\"{{!extract}}\"; s=s.split(\" \");s[6];")
set !var7 eval("var s=\"{{!extract}}\"; s=s.split(\" \");s[7];")
set !var8 eval("var s=\"{{!extract}}\"; s=s.split(\" \");s[8];")
set !var9 eval("var s=\"{{!extract}}\"; s=s.split(\" \");s[9];")
I am using: Browser: Google Chrome Version 105.0.5195.102 (Official Build) (64-bit)
iMacros Personal Edition License - Addon for Chrome -Version 10.1.1
Windows 10 (64-bit)
__undefined__Output you are getting for "some" Vars, well, that'll be normal if your "Phrase" sometimes contains less than 10 "Words"... => You'd need to add a Check on the Length of the Phrase if you want to avoid those... // And hum, do you "really" want to store those first 10 Words in 10 separate Vars, or is storing those first 10 Words (as a "truncated" Sentence) in just 1 single Var acceptable for you...? (Depends on what you then want to do with those 10 Words...)