How to format a large variable of text into smaller variables in JavaScript?How to validate an email address in JavaScriptHow do JavaScript closures work?How can I format numbers as currency string in JavaScript?How do I remove a property from a JavaScript object?How do you get a timestamp in JavaScript?How do I include a JavaScript file in another JavaScript file?How to replace all occurrences of a string?How to check whether a string contains a substring in JavaScript?How to format a JavaScript dateHow do I remove a particular element from an array in JavaScript?

What are these criss-cross patterns close to Cambridge Airport (UK)?

Pi to the power y, for small y's

Possible executive assistant job scam

CO₂ level is high enough that it reduces cognitive ability. Isn't that a reason to worry?

How do I find the unknown program enabled during Start-Up?

Should a middle class person emulate a very wealthy investor for % of cash hold?

A variation on Caesar

Why are Democrats mostly focused on increasing healthcare spending, rarely mentioning any proposals for decreasing the costs of healthcare services?

Older Road Bike Tire Size

A question about the に in this sentence

Simulate a pool using multithreading in Python

Very high precision zero crossing detection

Need Good OOP Design For World and Countries Problem

Do airplanes need brakes in the air?

What on earth is this small wall-mounted computer?

"Cобака на сене" - is this expression still in use or is it dated?

What do you call someone whose unmarried partner has died?

Can you make monkeys human?

Is a grommet needed for romex into this metal junction box?

How to make sure there's equal difference in length between lines

Can I scale all line widths in a tikzpicture?

How to import a ByteArray from GenerateHTTPResponse?

What is the meaning of Text inside of AMS logo

Is it unsafe to remove one stud from a load bearing wall?



How to format a large variable of text into smaller variables in JavaScript?


How to validate an email address in JavaScriptHow do JavaScript closures work?How can I format numbers as currency string in JavaScript?How do I remove a property from a JavaScript object?How do you get a timestamp in JavaScript?How do I include a JavaScript file in another JavaScript file?How to replace all occurrences of a string?How to check whether a string contains a substring in JavaScript?How to format a JavaScript dateHow do I remove a particular element from an array in JavaScript?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty
margin-bottom:0;









0

















I'm using an API to pull data through to my application, and I'm pulling an object and it's property, however the property is just a large wall of text (shown below). The reason I can't use all the text is well...Because n



Is it possible to format this wall of text into smaller variables or such?



My current code is finding the length from the start of the text to the first fullstop, then creating a variable with that length to grab the first sentence.



//what it currently shows//
"Leonard Shelby is tracking down the man who raped and murdered his wife.
The difficulty of locating his wife's killer, however, is compounded by
the fact that he suffers from a rare, untreatable form of short-term
memory loss. Although he can recall details of life before his accident,
Leonard cannot remember what happened fifteen minutes ago, where he's
going, or why."

//What I want it to look like
"Leonard Shelby is tracking down the man who raped and murdered his wife.

The difficulty of locating his wife's killer, however, is compounded by
the fact that he suffers from a rare, untreatable form of short-term
memory loss.

Although he can recall details of life before his accident,
Leonard cannot remember what happened fifteen minutes ago, where he's
going, or why."


//my code//
var fullTvShowOverview = tvShow.overview;
var tvShowOverView = document.getElementById("tvshow-description");

var trimmedTvShowLength = fullTvShowOverview.indexOf(".");
var trimmedTvShowOverview = fullTvShowOverview.substring(0,
trimmedTvShowLength, ".");
trimmedTvShowOverview = trimmedTvShowOverview + ".";
tvShowOverView.textContent = trimmedTvShowOverview;


//my code produces: "Leonard Shelby is tracking down the man who raped and murdered his wife."









share|improve this question


























  • what is your question? Your code seems to be doing what you're requesting already.

    – Steven Stark
    Mar 28 at 21:59











  • How can I get all of the text into smaller variables? My code get's the first sentence but how can I get all the other sentences into different variables?

    – TF120
    Mar 28 at 22:01












  • push each chunk into an array

    – Steven Stark
    Mar 28 at 22:03

















0

















I'm using an API to pull data through to my application, and I'm pulling an object and it's property, however the property is just a large wall of text (shown below). The reason I can't use all the text is well...Because n



Is it possible to format this wall of text into smaller variables or such?



My current code is finding the length from the start of the text to the first fullstop, then creating a variable with that length to grab the first sentence.



//what it currently shows//
"Leonard Shelby is tracking down the man who raped and murdered his wife.
The difficulty of locating his wife's killer, however, is compounded by
the fact that he suffers from a rare, untreatable form of short-term
memory loss. Although he can recall details of life before his accident,
Leonard cannot remember what happened fifteen minutes ago, where he's
going, or why."

//What I want it to look like
"Leonard Shelby is tracking down the man who raped and murdered his wife.

The difficulty of locating his wife's killer, however, is compounded by
the fact that he suffers from a rare, untreatable form of short-term
memory loss.

Although he can recall details of life before his accident,
Leonard cannot remember what happened fifteen minutes ago, where he's
going, or why."


//my code//
var fullTvShowOverview = tvShow.overview;
var tvShowOverView = document.getElementById("tvshow-description");

var trimmedTvShowLength = fullTvShowOverview.indexOf(".");
var trimmedTvShowOverview = fullTvShowOverview.substring(0,
trimmedTvShowLength, ".");
trimmedTvShowOverview = trimmedTvShowOverview + ".";
tvShowOverView.textContent = trimmedTvShowOverview;


//my code produces: "Leonard Shelby is tracking down the man who raped and murdered his wife."









share|improve this question


























  • what is your question? Your code seems to be doing what you're requesting already.

    – Steven Stark
    Mar 28 at 21:59











  • How can I get all of the text into smaller variables? My code get's the first sentence but how can I get all the other sentences into different variables?

    – TF120
    Mar 28 at 22:01












  • push each chunk into an array

    – Steven Stark
    Mar 28 at 22:03













0












0








0








I'm using an API to pull data through to my application, and I'm pulling an object and it's property, however the property is just a large wall of text (shown below). The reason I can't use all the text is well...Because n



Is it possible to format this wall of text into smaller variables or such?



My current code is finding the length from the start of the text to the first fullstop, then creating a variable with that length to grab the first sentence.



//what it currently shows//
"Leonard Shelby is tracking down the man who raped and murdered his wife.
The difficulty of locating his wife's killer, however, is compounded by
the fact that he suffers from a rare, untreatable form of short-term
memory loss. Although he can recall details of life before his accident,
Leonard cannot remember what happened fifteen minutes ago, where he's
going, or why."

//What I want it to look like
"Leonard Shelby is tracking down the man who raped and murdered his wife.

The difficulty of locating his wife's killer, however, is compounded by
the fact that he suffers from a rare, untreatable form of short-term
memory loss.

Although he can recall details of life before his accident,
Leonard cannot remember what happened fifteen minutes ago, where he's
going, or why."


//my code//
var fullTvShowOverview = tvShow.overview;
var tvShowOverView = document.getElementById("tvshow-description");

var trimmedTvShowLength = fullTvShowOverview.indexOf(".");
var trimmedTvShowOverview = fullTvShowOverview.substring(0,
trimmedTvShowLength, ".");
trimmedTvShowOverview = trimmedTvShowOverview + ".";
tvShowOverView.textContent = trimmedTvShowOverview;


//my code produces: "Leonard Shelby is tracking down the man who raped and murdered his wife."









share|improve this question















I'm using an API to pull data through to my application, and I'm pulling an object and it's property, however the property is just a large wall of text (shown below). The reason I can't use all the text is well...Because n



Is it possible to format this wall of text into smaller variables or such?



My current code is finding the length from the start of the text to the first fullstop, then creating a variable with that length to grab the first sentence.



//what it currently shows//
"Leonard Shelby is tracking down the man who raped and murdered his wife.
The difficulty of locating his wife's killer, however, is compounded by
the fact that he suffers from a rare, untreatable form of short-term
memory loss. Although he can recall details of life before his accident,
Leonard cannot remember what happened fifteen minutes ago, where he's
going, or why."

//What I want it to look like
"Leonard Shelby is tracking down the man who raped and murdered his wife.

The difficulty of locating his wife's killer, however, is compounded by
the fact that he suffers from a rare, untreatable form of short-term
memory loss.

Although he can recall details of life before his accident,
Leonard cannot remember what happened fifteen minutes ago, where he's
going, or why."


//my code//
var fullTvShowOverview = tvShow.overview;
var tvShowOverView = document.getElementById("tvshow-description");

var trimmedTvShowLength = fullTvShowOverview.indexOf(".");
var trimmedTvShowOverview = fullTvShowOverview.substring(0,
trimmedTvShowLength, ".");
trimmedTvShowOverview = trimmedTvShowOverview + ".";
tvShowOverView.textContent = trimmedTvShowOverview;


//my code produces: "Leonard Shelby is tracking down the man who raped and murdered his wife."






javascript formatting






share|improve this question














share|improve this question











share|improve this question




share|improve this question










asked Mar 28 at 21:54









TF120TF120

971 gold badge2 silver badges8 bronze badges




971 gold badge2 silver badges8 bronze badges















  • what is your question? Your code seems to be doing what you're requesting already.

    – Steven Stark
    Mar 28 at 21:59











  • How can I get all of the text into smaller variables? My code get's the first sentence but how can I get all the other sentences into different variables?

    – TF120
    Mar 28 at 22:01












  • push each chunk into an array

    – Steven Stark
    Mar 28 at 22:03

















  • what is your question? Your code seems to be doing what you're requesting already.

    – Steven Stark
    Mar 28 at 21:59











  • How can I get all of the text into smaller variables? My code get's the first sentence but how can I get all the other sentences into different variables?

    – TF120
    Mar 28 at 22:01












  • push each chunk into an array

    – Steven Stark
    Mar 28 at 22:03
















what is your question? Your code seems to be doing what you're requesting already.

– Steven Stark
Mar 28 at 21:59





what is your question? Your code seems to be doing what you're requesting already.

– Steven Stark
Mar 28 at 21:59













How can I get all of the text into smaller variables? My code get's the first sentence but how can I get all the other sentences into different variables?

– TF120
Mar 28 at 22:01






How can I get all of the text into smaller variables? My code get's the first sentence but how can I get all the other sentences into different variables?

– TF120
Mar 28 at 22:01














push each chunk into an array

– Steven Stark
Mar 28 at 22:03





push each chunk into an array

– Steven Stark
Mar 28 at 22:03












2 Answers
2






active

oldest

votes


















0


















You will want to split the text string into an array, and then loop the array for your processing later. Here's a minimal example that is splitting on just .






let textStr ="This. is some. example. text.";

let results = textStr.split(". ");

console.log( results[1] )








share|improve this answer

































    0


















    you can place in an array and just use the indices to access each sentence






    var fullTvShowOverview = "Leonard Shelby is tracking down the man who raped and murdered his wife.The difficulty of locating his wife's killer, however, is compounded by the fact that he suffers from a rare, untreatable form of short-term memory loss.Although he can recall details of life before his accident,Leonard cannot remember what happened fifteen minutes ago, where he's going, or why.";
    var tvShowOverView = document.getElementById("tvshow-description");

    var arraySplitByPeriod = fullTvShowOverview.split(".")

    tvShowOverView.textContent = arraySplitByPeriod[0];

    <div id="tvshow-description">

    <div>








    share|improve this answer



























      Your Answer






      StackExchange.ifUsing("editor", function ()
      StackExchange.using("externalEditor", function ()
      StackExchange.using("snippets", function ()
      StackExchange.snippets.init();
      );
      );
      , "code-snippets");

      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "1"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader:
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      ,
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );














      draft saved

      draft discarded
















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55407429%2fhow-to-format-a-large-variable-of-text-into-smaller-variables-in-javascript%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown


























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      0


















      You will want to split the text string into an array, and then loop the array for your processing later. Here's a minimal example that is splitting on just .






      let textStr ="This. is some. example. text.";

      let results = textStr.split(". ");

      console.log( results[1] )








      share|improve this answer






























        0


















        You will want to split the text string into an array, and then loop the array for your processing later. Here's a minimal example that is splitting on just .






        let textStr ="This. is some. example. text.";

        let results = textStr.split(". ");

        console.log( results[1] )








        share|improve this answer




























          0














          0










          0









          You will want to split the text string into an array, and then loop the array for your processing later. Here's a minimal example that is splitting on just .






          let textStr ="This. is some. example. text.";

          let results = textStr.split(". ");

          console.log( results[1] )








          share|improve this answer














          You will want to split the text string into an array, and then loop the array for your processing later. Here's a minimal example that is splitting on just .






          let textStr ="This. is some. example. text.";

          let results = textStr.split(". ");

          console.log( results[1] )








          let textStr ="This. is some. example. text.";

          let results = textStr.split(". ");

          console.log( results[1] )





          let textStr ="This. is some. example. text.";

          let results = textStr.split(". ");

          console.log( results[1] )






          share|improve this answer













          share|improve this answer




          share|improve this answer










          answered Mar 28 at 22:06









          Steven StarkSteven Stark

          1,0468 silver badges19 bronze badges




          1,0468 silver badges19 bronze badges


























              0


















              you can place in an array and just use the indices to access each sentence






              var fullTvShowOverview = "Leonard Shelby is tracking down the man who raped and murdered his wife.The difficulty of locating his wife's killer, however, is compounded by the fact that he suffers from a rare, untreatable form of short-term memory loss.Although he can recall details of life before his accident,Leonard cannot remember what happened fifteen minutes ago, where he's going, or why.";
              var tvShowOverView = document.getElementById("tvshow-description");

              var arraySplitByPeriod = fullTvShowOverview.split(".")

              tvShowOverView.textContent = arraySplitByPeriod[0];

              <div id="tvshow-description">

              <div>








              share|improve this answer






























                0


















                you can place in an array and just use the indices to access each sentence






                var fullTvShowOverview = "Leonard Shelby is tracking down the man who raped and murdered his wife.The difficulty of locating his wife's killer, however, is compounded by the fact that he suffers from a rare, untreatable form of short-term memory loss.Although he can recall details of life before his accident,Leonard cannot remember what happened fifteen minutes ago, where he's going, or why.";
                var tvShowOverView = document.getElementById("tvshow-description");

                var arraySplitByPeriod = fullTvShowOverview.split(".")

                tvShowOverView.textContent = arraySplitByPeriod[0];

                <div id="tvshow-description">

                <div>








                share|improve this answer




























                  0














                  0










                  0









                  you can place in an array and just use the indices to access each sentence






                  var fullTvShowOverview = "Leonard Shelby is tracking down the man who raped and murdered his wife.The difficulty of locating his wife's killer, however, is compounded by the fact that he suffers from a rare, untreatable form of short-term memory loss.Although he can recall details of life before his accident,Leonard cannot remember what happened fifteen minutes ago, where he's going, or why.";
                  var tvShowOverView = document.getElementById("tvshow-description");

                  var arraySplitByPeriod = fullTvShowOverview.split(".")

                  tvShowOverView.textContent = arraySplitByPeriod[0];

                  <div id="tvshow-description">

                  <div>








                  share|improve this answer














                  you can place in an array and just use the indices to access each sentence






                  var fullTvShowOverview = "Leonard Shelby is tracking down the man who raped and murdered his wife.The difficulty of locating his wife's killer, however, is compounded by the fact that he suffers from a rare, untreatable form of short-term memory loss.Although he can recall details of life before his accident,Leonard cannot remember what happened fifteen minutes ago, where he's going, or why.";
                  var tvShowOverView = document.getElementById("tvshow-description");

                  var arraySplitByPeriod = fullTvShowOverview.split(".")

                  tvShowOverView.textContent = arraySplitByPeriod[0];

                  <div id="tvshow-description">

                  <div>








                  var fullTvShowOverview = "Leonard Shelby is tracking down the man who raped and murdered his wife.The difficulty of locating his wife's killer, however, is compounded by the fact that he suffers from a rare, untreatable form of short-term memory loss.Although he can recall details of life before his accident,Leonard cannot remember what happened fifteen minutes ago, where he's going, or why.";
                  var tvShowOverView = document.getElementById("tvshow-description");

                  var arraySplitByPeriod = fullTvShowOverview.split(".")

                  tvShowOverView.textContent = arraySplitByPeriod[0];

                  <div id="tvshow-description">

                  <div>





                  var fullTvShowOverview = "Leonard Shelby is tracking down the man who raped and murdered his wife.The difficulty of locating his wife's killer, however, is compounded by the fact that he suffers from a rare, untreatable form of short-term memory loss.Although he can recall details of life before his accident,Leonard cannot remember what happened fifteen minutes ago, where he's going, or why.";
                  var tvShowOverView = document.getElementById("tvshow-description");

                  var arraySplitByPeriod = fullTvShowOverview.split(".")

                  tvShowOverView.textContent = arraySplitByPeriod[0];

                  <div id="tvshow-description">

                  <div>






                  share|improve this answer













                  share|improve this answer




                  share|improve this answer










                  answered Mar 28 at 22:09









                  OatmealOatmeal

                  73 bronze badges




                  73 bronze badges































                      draft saved

                      draft discarded















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid


                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.

                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55407429%2fhow-to-format-a-large-variable-of-text-into-smaller-variables-in-javascript%23new-answer', 'question_page');

                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown









                      Popular posts from this blog

                      Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                      SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

                      은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현