How to use regextras - 1 common examples

To help you get started, we’ve selected a few regextras examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github gajus / eslint-plugin-jsdoc / src / rules / requireDescriptionCompleteSentence.js View on Github external
const extractSentences = (text) => {
  const txt = text

    // Remove all {} tags.
    .replace(/\{[\s\S]*?\}\s*/gu, '');

  const sentenceEndGrouping = /([.?!])(?:\s+|$)/u;
  const puncts = RegExtras(sentenceEndGrouping).map(txt, (punct) => {
    return punct;
  });

  return txt

    .split(/[.?!](?:\s+|$)/u)

    // Re-add the dot.
    .map((sentence, idx) => {
      return /^\s*$/u.test(sentence) ? sentence : `${sentence}${puncts[idx] || ''}`;
    });
};

regextras

Array extras for regular expressions

MIT
Latest version published 4 years ago

Package Health Score

50 / 100
Full package analysis

Popular regextras functions