I don't know if what you want is attainable using Applescript. SGIII may, but, like me is puzzled by your description of what you want.
EDIT: Your response to SG's post clarifies the situation.
Is this an accurate description?
You are requesting two separate situations and a resut for each.
1
"that can get a specific word position from a sentence in a cell and return that words"
You will input:
a cell location
a 'position' within that cell.
You want this result:
the word that is in that location.
SG's response above fits this request and result for a text string written into the script (The quick brown…"), but not for a text string in a specified cell. Replacing "The quick brown…lazy dog." with a cell reference might be enough to fully fit your request.
2
"a function to separate a long word (underTheRain / UnderTheRain) into multiple words base on upper case like =separateWord(cell#) that return all words with space or underscore."
Here you give two examples of "a long word": 'underTheRain' and 'UnderTheRain'
For these, you want the results: 'under the rain' and 'Under The Rain' (or ' Under The Rain')
OR the results: 'under_The_Rain' and 'Under_The_Rain' (or '_Under_The_Rain')
Each of the 'long words' is the content of, or included in the content of a specified cell.
To do this, the script must be able to test a string two characters at a time, recognize whether a character is a space or is a lower case letter, AND whether the character following that one is an upper case character, then IF the first character is a lower case letter AND the second is an upper case character, to insert ether a space or an underscore character between the two; otherwise to make no change.
Another way to express the test(s):
The script must check each character of the string. If character n is anything but an upper case letter, the test passes on to the next character. If character n is an upper case letter, then the script checks the n-1 character. If that character is a lower case letter, the script inserts a space (or an underscore) between character n-1 and character n, and continues the tests, starting at character n+1 (original count).
On writing the previous paragraph, these thoughts arose:
The script probably needs to build a new string as it goes through the test of the existing string, adding letter by letter where the 'lower case letter followed by upper case letter' test returns false, and adding the space (or underscore) where the test returns true, then, when the test is finished for that cell, eplacinf the existing string with the newly constructed one.
Interesting problem. Can AppleScript, as applied to Numbers, handle it?
Regards,
Barry