Skip to content

Instantly share code, notes, and snippets.

@jsmithdev
Last active July 28, 2022 23:42
Show Gist options
  • Select an option

  • Save jsmithdev/0fedd6a02565c383af3fc4477bc23f26 to your computer and use it in GitHub Desktop.

Select an option

Save jsmithdev/0fedd6a02565c383af3fc4477bc23f26 to your computer and use it in GitHub Desktop.

Revisions

  1. jsmithdev revised this gist Jul 28, 2022. 1 changed file with 14 additions and 9 deletions.
    23 changes: 14 additions & 9 deletions RegexWC.js
    Original file line number Diff line number Diff line change
    @@ -1,12 +1,17 @@
    /**
    * Matches name of component - "ui-comp" from `<ui-comp class="ok">EVERYTHING</ui-comp>`; Returns array of matches;
    * regexr.com/6qp3v
    **/
    const reg = new RegExp(/(?<=<)((\w*)(-\w*))(-\w*)*/, 'g');

    /**
    * @description Matches name of component - "ui-comp" from `<ui-comp class="ok">EVERYTHING</ui-comp>`
    * @return {Array} array of matches
    * @demo regexr.com/6qp3v
    **/
    export function nameUse(s) {
    return s.match(new RegExp(/(?<=<)((\w*)(-\w*))(-\w*)*/, 'g'));
    }

    /**
    * Matches whole use of component `<ui-comp class="ok">EVERYTHING</ui-comp>`; Returns array of matches;
    * regexr.com/6qp45
    * @description Matches whole use of component `<ui-comp class="ok">EVERYTHING</ui-comp>`
    * @return {Array} array of matches
    * @demo regexr.com/6qp45
    **/
    const reg = new RegExp(/((<\w*)(-\w*).*)((.|\n)*)((<\/\w*)(-\w*).*)/, 'g');
    export function wholeUse(s) {
    return s.match(new RegExp(/((<\w*)(-\w*).*)((.|\n)*)((<\/\w*)(-\w*).*)/, 'g'));
    }
  2. jsmithdev created this gist Jul 28, 2022.
    12 changes: 12 additions & 0 deletions RegexWC.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    /**
    * Matches name of component - "ui-comp" from `<ui-comp class="ok">EVERYTHING</ui-comp>`; Returns array of matches;
    * regexr.com/6qp3v
    **/
    const reg = new RegExp(/(?<=<)((\w*)(-\w*))(-\w*)*/, 'g');


    /**
    * Matches whole use of component `<ui-comp class="ok">EVERYTHING</ui-comp>`; Returns array of matches;
    * regexr.com/6qp45
    **/
    const reg = new RegExp(/((<\w*)(-\w*).*)((.|\n)*)((<\/\w*)(-\w*).*)/, 'g');