You need to share an example of how you are presently using Split() and the “text” you are passing into it for anyone to be able to help you.
Is there a reason you are using Scripting block to do this instead of formula fields?
Assuming that your tweet will always be considerably less than 490 words, and that the words are less than 20 characters, you can do this with formula fields.
For the first tweet, if the tweet is over 256 characters, use the tweet up to the first space after the 236th character:
IF(
LEN({tweet}) > 256,
LEFT(
{tweet},
FIND(" ", {tweet},LEN({tweet})-20)
),
{tweet}
)
For the second tweet, use the rest of the string after the space identified.:
IF(
LEN({tweet}) > 256,
REPLACE(
{tweet},
1,
FIND(" ", {tweet},LEN({tweet})-20),
""
)
)
If you really want a JavaScript solution, you can use various string methods.
Use substr() to extract the first 256 characters
Use lastIndexOf() to find the position of the last space before the 256th character
Use slice() to get the first portion of the tweet (based on the position identified in step 2.
Use slice() to get the second portion of the tweet (based on the position identified in step 2.
Is there a reason you are using Scripting block to do this instead of formula fields?
Assuming that your tweet will always be considerably less than 490 words, and that the words are less than 20 characters, you can do this with formula fields.
For the first tweet, if the tweet is over 256 characters, use the tweet up to the first space after the 236th character:
IF(
LEN({tweet}) > 256,
LEFT(
{tweet},
FIND(" ", {tweet},LEN({tweet})-20)
),
{tweet}
)
For the second tweet, use the rest of the string after the space identified.:
IF(
LEN({tweet}) > 256,
REPLACE(
{tweet},
1,
FIND(" ", {tweet},LEN({tweet})-20),
""
)
)
Can you help clarify what to input here? I’m trying to get a field that splits my “caption” field automatically into tweets as you indicate. Does the Formula field need to be named Tweet? Thanks for your help.
Can you help clarify what to input here? I’m trying to get a field that splits my “caption” field automatically into tweets as you indicate. Does the Formula field need to be named Tweet? Thanks for your help.
Welcome to the Airtable community!
In my formula fields, {tweet} happens to be the name of the original text field containing the text. You can replace it with {caption} or whatever is the name of your original text field, as long as you replace it everywhere it occurs. You can also name the formula field whatever you want. The name of the formula field doesn’t affect the formula itself.
Welcome to the Airtable community!
In my formula fields, {tweet} happens to be the name of the original text field containing the text. You can replace it with {caption} or whatever is the name of your original text field, as long as you replace it everywhere it occurs. You can also name the formula field whatever you want. The name of the formula field doesn’t affect the formula itself.