title: using regexreplace in sheets to join elements with a comma
body: <p>I want to join with a comma several words than can be found in a cell by joining them with a comma.</p>
  <p>For example, from a cell that contains :</p>
  <pre><code>i want to use sheets to create events in calendar through gmail.
  </code></pre>
  <p>I want this output :
  sheets, gmail, calendar</p>
  <p>I tried a regexreplace like this:</p>
  <pre><code>=ArrayFormula(IFERROR(REGEXREPLACE(LOWER(A2:A);&quot;(.)?(sheets|calendar|gmail)?&quot;;&quot;$2, &quot;))))&quot;
  </code></pre>
  <p>But I get various results like this :
  , , , , sheets, , , , , , , , , , calendar, , , , , , , ,
  , , , sheets, , , , , gmail, , , , ,
  , , , , , , , gmail, , , calendar, , , , , , , , , , ,</p>
  <p>I would like to know how to clean it like this:
  sheets, calendar
  sheets, gmail
  gmail, calendar</p>
  <p>to get rid of the useless commas before in between and after
  so far, using a more complex formula, i can get this :</p>
  <pre><code>=ArrayFormula(IFERROR(REGEXREPLACE(REGEXREPLACE(MINUSCULE(A2:A);&quot;(.)?(sheets|calendar|gmail)&quot;;&quot;$2, &quot;);&quot;(, )+&quot;;&quot;, &quot;)))
  </code></pre>
  <p>Still, the result is not perfect, since i get this :
  , sheets, calendar,
  , sheets, gmail,
  , gmail, calendar,</p>
  <p>And I am using twice the regexreplace formula.
  By the way, i could do it using join, or textjoin, but it is not working with arrayformula for a whole column, so it would not be appropriate.</p>
  <p>I think this is possible using () to capture elements, but I know some are real experts when it comes to this regex!</p>
  <p>Do you have an idea ?</p>