title: Trouble Adding Array output to an Dynamically Generated HTML String in GAS Google Script
body: <p>I am trying to automate my businesses blog. I want to create a dynamic html string to use as a wordpress blog description.  I am pulling text data from email body's in my gmail account to use as information.  I parse the email body using the first function below. </p>
  
  <p>I have everything working properly except for the for loop (in the second code block) creating the description of the post.  I have searched for hours and tried dozens of different techniques but I cant figure it out for the life of me.</p>
  
  <p>Here is how I am reading the text values into an array:</p>
  
  <pre><code> function getMatches(string, regex, index) { 
      index || (index = 1); // default to the first capturing group
      var matches = [];
      var match;
      while (match = regex.exec(string)) {
        matches.push(match[index]);
    }
    return matches;
  }
  </code></pre>
  
  <p>This is how I am trying to dynamically output the text arrays to create a basic HTML blogpost description (which I pass to xmlrpc to post):</p>
  
  <pre><code>    var1 = getMatches(string, regex expression, 1);
      var2 = getMatches(string, regex expression, 1);
      var3 = getMatches(string, regex expression, 1);
      var3 = getMatches(string, regex expression, 1);
      var fulldesc = "&lt;center&gt;";
      var text = "";
      for (var k=0; k&lt;var1.length; k++) {        
  
        text = "&lt;u&gt;&lt;b&gt;Var 1:&lt;/u&gt;&lt;/b&gt; " + var1[k] + ", &lt;u&gt;&lt;b&gt;Var 2:&lt;/u&gt;&lt;/b&gt; " + var2[k] + ", &lt;u&gt;&lt;b&gt;Var 3:&lt;/u&gt;&lt;/b&gt; " + var3[k] + ", &lt;u&gt;&lt;b&gt;Var 4:&lt;/u&gt;&lt;/b&gt; " + var4[k] + ", &lt;br&gt;&lt;br&gt;";          
        fulldesc += text;
      }
      fulldesc += "&lt;/center&gt;";
  </code></pre>
  
  <p>Lastly here is the blog post description code (using GAS XMLRPC library):</p>
  
  <pre><code>    var fullBlog = "&lt;b&gt;&lt;u&gt;Headline:&lt;/u&gt; " + sub + "&lt;/b&gt;&lt;br&gt;&lt;br&gt;" + fulldesc + "&lt;br&gt;&lt;br&gt;General Description: " + desc;
      var blogPost = {
          post_type: 'post',
          post_status: 'publish',      // Set to draft or publish
          title: 'Ticker: ' + sub,     //sub is from gmail subject and works fine
          categories: cat,             //cat is defined elsewhere and works fine
          date_created_gmt: pubdate2, //defined elsewhere (not working but thats another topic)
          mt_allow_comments: 'closed',
          description: fullBlog
        };
  
        request.addParam(blogPost);
  </code></pre>
  
  <p>If there's only one value in the var1,2,3,4 arrays all works as it should.  But any more than 1 value and I get no output at all from the "fulldesc" var.  All other text variables work as they should and the blog still gets posted (just minus some very important information).  I'm pretty sure the problem lies in my for loop which adds the HTML description to text var.  </p>
  
  <p>Any suggestions would be greatly appreciated, I'm burned out trying to get the answer! I am a self taught programmer (just from reading this forum) so please go easy on me if I missed something stupid :)</p>