.
It receives a pattern and a replacement value,
and substitutes the replacement value for all occurrences of the pattern
in a given string:
</p>
<pre class="example">
function gsub (s, patt, repl)
  patt = lpeg.P(patt)
  patt = lpeg.Cs((patt / repl + 1)^0)
  return lpeg.match(patt, s)
end
</pre>
<p>
As in <code>string.gsub</code>,
the replacement value can be a string,
a function, or a table.
</p>


<h3><a name="CSV"></a>Comma-Separated Values (CSV)</h3>
<p>
This example breaks a string into comma-separate