Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Split() After Specific Number of Words/Characters?

Engaged ,
Aug 10, 2022 Aug 10, 2022

Greetings all,

 

Got another one that's probably simpler than I'm making it. This is what I'm trying to do:

 

I have a slider named "Camera Input Talent 1 Scale Adjust." Ideally, I'd like to be able to pull two strings from this:

string1 = "Camera Input Talent 1"

string2 = "Scale Adjust"

 

I like the split() function because it splits a string into an array, but all the references I've been able to find indicate that split() will only work with a delimiter that's a character. Is there a way to either get split() to work with a number of characters or a number of words? Or some other way to do what I'm describing?

TOPICS
Expressions , How to
288
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Aug 10, 2022 Aug 10, 2022

There might be a simpler way, but I think this will work:

 

str = "Camera Input Talent 1 Scale Adjust.";
numWords = 4;

arr = str.split(" ");
arr1 = arr.slice(0,numWords);
arr2 = arr.slice(numWords);
arr1.join(" ") + "\r" + arr2.join(" ");

 

Translate
Community Expert ,
Aug 10, 2022 Aug 10, 2022

There might be a simpler way, but I think this will work:

 

str = "Camera Input Talent 1 Scale Adjust.";
numWords = 4;

arr = str.split(" ");
arr1 = arr.slice(0,numWords);
arr2 = arr.slice(numWords);
arr1.join(" ") + "\r" + arr2.join(" ");

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Aug 10, 2022 Aug 10, 2022
LATEST

Dan does it again! As always you know I appreciate it!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines