Skip to content
Standard library

velt/text#

import { RegExp, StringBuilder, escapeHtml } from "velt/text". Text processing:

  • Regular expressions: RegExp (also a global, as are regex literals), its matches (RegExpMatch), RegExpError, and the Pattern interface RegExp implements.
  • StringBuilder (also a global): a string built by appending, returned without a copy.
  • HTML escaping: escapeHtml(s), for element content and quoted attribute values.
ts
import { escapeHtml } from "velt/text";

const words = "one, two,three".split(/,\s*/);
const b = new StringBuilder();
for (const w of words) b.append(`<li>${escapeHtml(w)}</li>`);
console.log(b.take()); // <li>one</li><li>two</li><li>three</li>

Edit this page on GitHub