How to use clone-regexp - 3 common examples

To help you get started, we’ve selected a few clone-regexp 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 jamesramsay / hercule / src / transclude.js View on Github external
export default function Transclude(source = 'string', options = {}) {
  const {
    transclusionSyntax = 'hercule',
    inheritedParents = [],
    inheritedReferences = [],
    inheritedIndent = '',
    resolvers,
  } = options;
  const { REGEXP, MATCH_GROUP, INDENT_GROUP, LINK_GROUP } = SYNTAX[
    transclusionSyntax
  ];
  const pattern = cloneRegExp(REGEXP);
  let inputBuffer = '';
  let line = 1;
  let column = 0;

  function transclude(chunk, cb) {
    const self = this;

    // eslint-disable-next-line consistent-return
    process.nextTick(() => {
      if (!chunk.link) {
        self.push(chunk);
        return cb();
      }

      const { parents, indent, content } = chunk;
      const sourceLine = chunk.line;
github mattzeunert / FromJS / src / tracing / FromJSString.js View on Github external
runFunctionWithTracingDisabled(function(){
                            var regExp = cloneRegExp(separator, {global: true})
                            separators = oldString.match(regExp)
                            if (separators === null) {
                                separators = [];
                            }
                        })
                    } else {
github AlbertLucianto / vue-text-highlight / src / utils / indicesOf.js View on Github external
export default function indicesOf(text, searchStringOrRegex, caseSensitive = false) {
  if (searchStringOrRegex instanceof RegExp) {
    const re = cloneRegexp(searchStringOrRegex, { global: true });
    const indices = [];

    let match = re.exec(text);
    while (match) {
      const offset = match.index + match[0].length;
      indices.push([match.index, offset]);
      match = re.exec(text);
    }
    return indices;
  }
  const searchStringLen = searchStringOrRegex.length;

  if (searchStringLen === 0) {
    return [];
  }

clone-regexp

Clone and modify a RegExp instance

MIT
Latest version published 3 years ago

Package Health Score

67 / 100
Full package analysis

Popular clone-regexp functions