Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

regex

Package Overview
Dependencies
Maintainers
0
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

regex - npm Package Compare versions

Comparing version 4.1.0 to 4.1.1

20

dist/regex.min.js

@@ -1,2 +0,2 @@

var Regex=(()=>{var q=Object.defineProperty;var Te=Object.getOwnPropertyDescriptor;var Se=Object.getOwnPropertyNames;var Le=Object.prototype.hasOwnProperty;var $e=(e,t)=>{for(var n in t)q(e,n,{get:t[n],enumerable:!0})},Ie=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Se(t))!Le.call(e,o)&&o!==n&&q(e,o,{get:()=>t[o],enumerable:!(r=Te(t,o))||r.enumerable});return e};var Ce=e=>Ie(q({},"__esModule",{value:!0}),e);var He={};$e(He,{pattern:()=>j,regex:()=>ye});var d=Object.freeze({DEFAULT:"DEFAULT",CHAR_CLASS:"CHAR_CLASS"});function N(e,t,n,r){let o=new RegExp(`${t}|(?<skip>\\\\?.)`,"gsu"),u=0,s="";for(let i of e.matchAll(o)){let{0:l,groups:{skip:f}}=i;if(!f&&(!r||r===d.DEFAULT==!u)){n instanceof Function?s+=n(i):s+=n;continue}l==="["?u++:l==="]"&&u&&u--,s+=l}return s}function G(e,t,n,r){N(e,t,n,r)}function V(e,t,n=0,r){if(!new RegExp(t,"su").test(e))return null;let o=new RegExp(`${t}|(?<skip>\\\\?.)`,"gsu");o.lastIndex=n;let u=0,s;for(;s=o.exec(e);){let{0:i,groups:{skip:l}}=s;if(!l&&(!r||r===d.DEFAULT==!u))return s;i==="["?u++:i==="]"&&u&&u--,o.lastIndex==s.index&&o.lastIndex++}return null}function _(e,t,n){return!!V(e,t,0,n)}function W(e,t){let n=/\\?./gsu;n.lastIndex=t;let r=e.length,o=0,u=1,s;for(;s=n.exec(e);){let[i]=s;if(i==="[")o++;else if(o)i==="]"&&o--;else if(i==="(")u++;else if(i===")"&&(u--,!u)){r=s.index;break}}return e.slice(t,r)}var I=class{#e;constructor(t){this.#e=t}toString(){return String(this.#e)}};function j(e,...t){if(Array.isArray(e?.raw))return new I(e.raw.flatMap((n,r)=>r<e.raw.length-1?[n,t[r]]:n).join(""));if(!t.length)return new I(e??"");throw new Error(`Unexpected arguments: ${JSON.stringify([e,...t])}`)}var c={DEFAULT:"R_DEFAULT",CHAR_CLASS:"R_CHAR_CLASS",GROUP_NAME:"R_GROUP_NAME",ENCLOSED_TOKEN:"R_ENCLOSED_TOKEN",INTERVAL_QUANTIFIER:"R_INTERVAL_QUANTIFIER",INVALID_INCOMPLETE_TOKEN:"R_INVALID_INCOMPLETE_TOKEN"},m={DEFAULT:"CC_DEFAULT",RANGE:"CC_RANGE",ENCLOSED_TOKEN:"CC_ENCLOSED_TOKEN",Q_TOKEN:"CC_Q_TOKEN",INVALID_INCOMPLETE_TOKEN:"CC_INVALID_INCOMPLETE_TOKEN"},K=(()=>{try{new RegExp("(?i:)")}catch{return!1}return!0})(),oe=(()=>{try{new RegExp("","v")}catch{return!1}return!0})(),R="&!#$%*+,.:;<=>?@^`~",$="$E$",Q=String.raw`\(\?<(?![=!])(?<captureName>[^>]+)>`,b=String.raw`\((?!\?)(?!(?<=\(\?\()DEFINE\))|${Q}`,U=String.raw`\(\?(?:[:=!>A-Za-z\-]|<[=!]|\(DEFINE\))`;function B(e,t){return t===d.CHAR_CLASS?e.replace(new RegExp(String.raw`[()\[\]{}|\\/\-${R}]`,"g"),"\\$&"):e.replace(/[()\[\]{}|\\^$*+?.]/g,"\\$&")}function H(e){return e.replace(new RegExp(`^([${R}])(?!\\1)`),(t,n,r)=>`\\${t}${r+1===e.length?"":t}`)}function se(e){return e.replace(/^\^/,"\\^^")}function M(e,t){return N(e,String.raw`\\0(?!\d)`,"\\u{0}",t)}function ne(e,t,n){let r=0;for(let[o]of e.matchAll(new RegExp(`[${B(t+n,d.CHAR_CLASS)}]`,"g")))if(r+=o===t?1:-1,r<0)return n;return r>0?t:""}function ie(e,t,n){let r=e.replace(/\\./gsu,"");if(r.endsWith("\\"))return"\\";if(t===c.DEFAULT)return ne(r,"(",")");if(t===c.CHAR_CLASS&&!(n===m.ENCLOSED_TOKEN||n===m.Q_TOKEN))return ne(r,"[","]");if(t===c.ENCLOSED_TOKEN||t===c.INTERVAL_QUANTIFIER||n===m.ENCLOSED_TOKEN||n===m.Q_TOKEN){if(r.includes("}"))return"}"}else if(t===c.GROUP_NAME&&r.includes(">"))return">";return""}var re=new RegExp(String.raw`
var Regex=(()=>{var H=Object.defineProperty;var Te=Object.getOwnPropertyDescriptor;var Se=Object.getOwnPropertyNames;var $e=Object.prototype.hasOwnProperty;var Le=(e,t)=>{for(var n in t)H(e,n,{get:t[n],enumerable:!0})},Ie=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Se(t))!$e.call(e,o)&&o!==n&&H(e,o,{get:()=>t[o],enumerable:!(r=Te(t,o))||r.enumerable});return e};var Ce=e=>Ie(H({},"__esModule",{value:!0}),e);var qe={};Le(qe,{pattern:()=>j,regex:()=>ye});var d=Object.freeze({DEFAULT:"DEFAULT",CHAR_CLASS:"CHAR_CLASS"});function A(e,t,n,r){let o=new RegExp(`${t}|(?<skip>\\\\?.)`,"gsu"),u=0,s="";for(let i of e.matchAll(o)){let{0:l,groups:{skip:f}}=i;if(!f&&(!r||r===d.DEFAULT==!u)){n instanceof Function?s+=n(i):s+=n;continue}l==="["?u++:l==="]"&&u&&u--,s+=l}return s}function G(e,t,n,r){A(e,t,n,r)}function V(e,t,n=0,r){if(!new RegExp(t,"su").test(e))return null;let o=new RegExp(`${t}|(?<skip>\\\\?.)`,"gsu");o.lastIndex=n;let u=0,s;for(;s=o.exec(e);){let{0:i,groups:{skip:l}}=s;if(!l&&(!r||r===d.DEFAULT==!u))return s;i==="["?u++:i==="]"&&u&&u--,o.lastIndex==s.index&&o.lastIndex++}return null}function _(e,t,n){return!!V(e,t,0,n)}function W(e,t){let n=/\\?./gsu;n.lastIndex=t;let r=e.length,o=0,u=1,s;for(;s=n.exec(e);){let[i]=s;if(i==="[")o++;else if(o)i==="]"&&o--;else if(i==="(")u++;else if(i===")"&&(u--,!u)){r=s.index;break}}return e.slice(t,r)}var L=class{#e;constructor(t){this.#e=t}toString(){return String(this.#e)}};function j(e,...t){if(Array.isArray(e?.raw))return new L(e.raw.flatMap((n,r)=>r<e.raw.length-1?[n,t[r]]:n).join(""));if(!t.length)return new L(e??"");throw new Error(`Unexpected arguments: ${JSON.stringify([e,...t])}`)}var c={DEFAULT:"R_DEFAULT",CHAR_CLASS:"R_CHAR_CLASS",GROUP_NAME:"R_GROUP_NAME",ENCLOSED_TOKEN:"R_ENCLOSED_TOKEN",INTERVAL_QUANTIFIER:"R_INTERVAL_QUANTIFIER",INVALID_INCOMPLETE_TOKEN:"R_INVALID_INCOMPLETE_TOKEN"},g={DEFAULT:"CC_DEFAULT",RANGE:"CC_RANGE",ENCLOSED_TOKEN:"CC_ENCLOSED_TOKEN",Q_TOKEN:"CC_Q_TOKEN",INVALID_INCOMPLETE_TOKEN:"CC_INVALID_INCOMPLETE_TOKEN"},M=(()=>{try{new RegExp("(?i:)")}catch{return!1}return!0})(),oe=(()=>{try{new RegExp("","v")}catch{return!1}return!0})(),R="&!#$%*+,.:;<=>?@^`~",I="$E$",Q=String.raw`\(\?<(?![=!])(?<captureName>[^>]+)>`,b=String.raw`\((?!\?)(?!(?<=\(\?\()DEFINE\))|${Q}`,U=String.raw`\(\?(?:[:=!>A-Za-z\-]|<[=!]|\(DEFINE\))`;function B(e,t){return t===d.CHAR_CLASS?e.replace(new RegExp(String.raw`[()\[\]{}|\\/\-${R}]`,"g"),"\\$&"):e.replace(/[()\[\]{}|\\^$*+?.]/g,"\\$&")}function q(e){return e.replace(new RegExp(`^([${R}])(?!\\1)`),(t,n,r)=>`\\${t}${r+1===e.length?"":t}`)}function se(e){return e.replace(/^\^/,"\\^^")}function K(e,t){return A(e,String.raw`\\0(?!\d)`,"\\u{0}",t)}function ne(e,t,n){let r=0;for(let[o]of e.matchAll(new RegExp(`[${B(t+n,d.CHAR_CLASS)}]`,"g")))if(r+=o===t?1:-1,r<0)return n;return r>0?t:""}function ie(e,t,n){let r=e.replace(/\\./gsu,"");if(r.endsWith("\\"))return"\\";if(t===c.DEFAULT)return ne(r,"(",")");if(t===c.CHAR_CLASS&&!(n===g.ENCLOSED_TOKEN||n===g.Q_TOKEN))return ne(r,"[","]");if(t===c.ENCLOSED_TOKEN||t===c.INTERVAL_QUANTIFIER||n===g.ENCLOSED_TOKEN||n===g.Q_TOKEN){if(r.includes("}"))return"}"}else if(t===c.GROUP_NAME&&r.includes(">"))return">";return""}var re=new RegExp(String.raw`
(?<groupN>\(\?<(?![=!])|\\[gk]<)

@@ -14,3 +14,3 @@ | (?<enclosedT>\\[pPu]\{)

| \\?.
`.replace(/\s+/g,""),"gsu");function F(e,{regexContext:t=c.DEFAULT,charClassContext:n=m.DEFAULT,charClassDepth:r=0,lastPos:o=0}={}){re.lastIndex=o;let u;for(;u=re.exec(e);){let{0:s,groups:{groupN:i,enclosedT:l,qT:f,intervalQ:p,incompleteT:a}}=u;s==="["?(r++,t=c.CHAR_CLASS,n=m.DEFAULT):s==="]"&&t===c.CHAR_CLASS?(r&&r--,r||(t=c.DEFAULT),n=m.DEFAULT):t===c.CHAR_CLASS?a?n=m.INVALID_INCOMPLETE_TOKEN:s==="-"?n=m.RANGE:l?n=m.ENCLOSED_TOKEN:f?n=m.Q_TOKEN:(s==="}"&&(n===m.ENCLOSED_TOKEN||n===m.Q_TOKEN)||n===m.INVALID_INCOMPLETE_TOKEN||n===m.RANGE)&&(n=m.DEFAULT):a?t=c.INVALID_INCOMPLETE_TOKEN:i?t=c.GROUP_NAME:l?t=c.ENCLOSED_TOKEN:p?t=c.INTERVAL_QUANTIFIER:(s===">"&&t===c.GROUP_NAME||s==="}"&&(t===c.ENCLOSED_TOKEN||t===c.INTERVAL_QUANTIFIER)||t===c.INVALID_INCOMPLETE_TOKEN)&&(t=c.DEFAULT)}return{regexContext:t,charClassContext:n,charClassDepth:r,lastPos:e.length}}function k(e){let t=0;return G(e,b,()=>t++,d.DEFAULT),t}function ue(e,t){return N(e,String.raw`\\(?<num>[1-9]\d*)`,({groups:{num:n}})=>`\\${+n+t}`,d.DEFAULT)}var _e=["Basic_Emoji","Emoji_Keycap_Sequence","RGI_Emoji_Modifier_Sequence","RGI_Emoji_Flag_Sequence","RGI_Emoji_Tag_Sequence","RGI_Emoji_ZWJ_Sequence","RGI_Emoji"].join("|"),De=new RegExp(String.raw`
`.replace(/\s+/g,""),"gsu");function F(e,{regexContext:t=c.DEFAULT,charClassContext:n=g.DEFAULT,charClassDepth:r=0,lastPos:o=0}={}){re.lastIndex=o;let u;for(;u=re.exec(e);){let{0:s,groups:{groupN:i,enclosedT:l,qT:f,intervalQ:E,incompleteT:a}}=u;s==="["?(r++,t=c.CHAR_CLASS,n=g.DEFAULT):s==="]"&&t===c.CHAR_CLASS?(r&&r--,r||(t=c.DEFAULT),n=g.DEFAULT):t===c.CHAR_CLASS?a?n=g.INVALID_INCOMPLETE_TOKEN:s==="-"?n=g.RANGE:l?n=g.ENCLOSED_TOKEN:f?n=g.Q_TOKEN:(s==="}"&&(n===g.ENCLOSED_TOKEN||n===g.Q_TOKEN)||n===g.INVALID_INCOMPLETE_TOKEN||n===g.RANGE)&&(n=g.DEFAULT):a?t=c.INVALID_INCOMPLETE_TOKEN:i?t=c.GROUP_NAME:l?t=c.ENCLOSED_TOKEN:E?t=c.INTERVAL_QUANTIFIER:(s===">"&&t===c.GROUP_NAME||s==="}"&&(t===c.ENCLOSED_TOKEN||t===c.INTERVAL_QUANTIFIER)||t===c.INVALID_INCOMPLETE_TOKEN)&&(t=c.DEFAULT)}return{regexContext:t,charClassContext:n,charClassDepth:r,lastPos:e.length}}function k(e){let t=0;return G(e,b,()=>t++,d.DEFAULT),t}function ue(e,t){return A(e,String.raw`\\(?<num>[1-9]\d*)`,({groups:{num:n}})=>`\\${+n+t}`,d.DEFAULT)}var _e=["Basic_Emoji","Emoji_Keycap_Sequence","RGI_Emoji_Modifier_Sequence","RGI_Emoji_Flag_Sequence","RGI_Emoji_Tag_Sequence","RGI_Emoji_ZWJ_Sequence","RGI_Emoji"].join("|"),De=new RegExp(String.raw`
\\(?: c[A-Za-z]

@@ -27,3 +27,3 @@ | p\{(?<pStrProp>${_e})\}

| .
`.replace(/\s+/g,""),"gsu");function z(e){let t=!1,n;for(let{0:r,groups:o}of e.matchAll(De)){if(o.pStrProp||o.qStrProp||r==="["&&t)return!0;if(["-","--","&&"].includes(r))t=!1;else if(r!=="["&&r!=="]"){if(t||n==="]")return!0;t=!0}n=r}return!1}function Z(e,t,n){let r={raw:[]},o=[],u;return e.raw.forEach((s,i)=>{let l=n(s,{...u,lastPos:0});if(r.raw.push(l.transformed),u=l.runningContext,i<e.raw.length-1){let f=t[i];if(f instanceof I){let p=n(f,{...u,lastPos:0});o.push(j(p.transformed)),u=p.runningContext}else o.push(f)}}),{template:r,substitutions:o}}var Oe=new RegExp(String.raw`
`.replace(/\s+/g,""),"gsu");function z(e){let t=!1,n;for(let{0:r,groups:o}of e.matchAll(De)){if(o.pStrProp||o.qStrProp||r==="["&&t)return!0;if(["-","--","&&"].includes(r))t=!1;else if(r!=="["&&r!=="]"){if(t||n==="]")return!0;t=!0}n=r}return!1}function Z(e,t,n){let r={raw:[]},o=[],u;return e.raw.forEach((s,i)=>{let l=n(s,{...u,lastPos:0});if(r.raw.push(l.transformed),u=l.runningContext,i<e.raw.length-1){let f=t[i];if(f instanceof L){let E=n(f,{...u,lastPos:0});o.push(j(E.transformed)),u=E.runningContext}else o.push(f)}}),{template:r,substitutions:o}}var Oe=new RegExp(String.raw`
${U}

@@ -47,4 +47,4 @@ | \(\?<

| \\?.
`.replace(/\s+/g,""),"gsu");function fe(e,t){e=String(e);let n=!1,r=!1,o=!1,u="",s="",i="",l="",f=!1,p=(a,{prefix:g=!0,postfix:E=!1}={})=>(a=(f&&g?"(?:)":"")+a+(E?"(?:)":""),f=!1,a);for(let[a]of e.matchAll(Ue)){if(o){a===`
`&&(o=!1,f=!0);continue}if(n){if(le.test(a))continue;n=!1,f=!0}else if(r){if(ce.test(a))continue;r=!1}u+=a,t=F(u,t);let{regexContext:g,charClassContext:E}=t;if(a==="-"&&g===c.CHAR_CLASS&&l===m.RANGE)throw new Error("Invalid unescaped hyphen as the end value for a range");if(g===c.DEFAULT&&/^(?:[?*+]|\?\?)$/.test(a)||g===c.INTERVAL_QUANTIFIER&&a==="{")s+=p(a,{prefix:!1,postfix:i==="("&&a==="?"});else if(g===c.DEFAULT)le.test(a)?n=!0:a.startsWith("#")?o=!0:Re.test(a)?s+=p(a[1],{prefix:!1}):s+=p(a);else if(g===c.CHAR_CLASS&&a!=="["&&a!=="[^")if(ce.test(a)&&(E===m.DEFAULT||E===m.RANGE||E===m.Q_TOKEN))r=!0;else{if(E===m.INVALID_INCOMPLETE_TOKEN)throw new Error(`Invalid incomplete token in character class: "${a}"`);be.test(a)&&(E===m.DEFAULT||E===m.Q_TOKEN)?s+=p(a[1],{prefix:!1}):E===m.DEFAULT?s+=p(H(M(a))):s+=p(a)}else s+=p(a);n||r||o||(i=a,l=E)}return{transformed:s,runningContext:t}}function pe(e){let t=String.raw`\(\?:\)`;e=N(e,`(?:${t}){2,}`,"(?:)",d.DEFAULT);let n=$.replace(/\$/g,"\\$");return e=N(e,String.raw`(?:${t}(?=[)|.[$\\]|\((?!DEFINE)|$)|(?<=[()|.\]^>]|\\[bBdDfnrsStvwW]|\(\?(?:[:=!]|<[=!])|^)${t}(?![?*+{]))(?!${n})`,"",d.DEFAULT),e}var Ee=new RegExp(String.raw`(?<noncapturingStart>${U})|(?<capturingStart>\((?:\?<[^>]+>)?)|\\?.`,"gsu");function de(e,t){if(!_(e,"\\(\\?>",d.DEFAULT))return e;let n="(?>",r=`(?:(?=(${t.useEmulationGroups?$:""}`,o=[0],u=0,s=0,i=NaN,l;do{l=!1;let f=0,p=0,a=!1,g;for(Ee.lastIndex=Number.isNaN(i)?0:i+r.length;g=Ee.exec(e);){let{0:E,index:A,groups:{capturingStart:h,noncapturingStart:S}}=g;if(E==="[")f++;else if(f)E==="]"&&f--;else if(E===n&&!a)i=A,a=!0;else if(a&&S)p++;else if(h)a?p++:(u++,o.push(u+s));else if(E===")"&&a){if(!p){s++,e=`${e.slice(0,i)}${r}${e.slice(i+n.length,A)}))<$$${s+u}>)${e.slice(A+1)}`,l=!0;break}p--}}}while(l);return e=N(e,String.raw`\\(?<backrefNum>[1-9]\d*)|<\$\$(?<wrappedBackrefNum>\d+)>`,({0:f,groups:{backrefNum:p,wrappedBackrefNum:a}})=>{if(p){let g=+p;if(g>o.length-1)throw new Error(`Backref "${f}" greater than number of captures`);return`\\${o[g]}`}return`\\${a}`},d.DEFAULT),e}var ge=String.raw`(?:[?*+]|\{\d+(?:,\d*)?\})`,Fe=new RegExp(String.raw`
`.replace(/\s+/g,""),"gsu");function fe(e,t){e=String(e);let n=!1,r=!1,o=!1,u="",s="",i="",l="",f=!1,E=(a,{prefix:m=!0,postfix:p=!1}={})=>(a=(f&&m?"(?:)":"")+a+(p?"(?:)":""),f=!1,a);for(let[a]of e.matchAll(Ue)){if(o){a===`
`&&(o=!1,f=!0);continue}if(n){if(le.test(a))continue;n=!1,f=!0}else if(r){if(ce.test(a))continue;r=!1}u+=a,t=F(u,t);let{regexContext:m,charClassContext:p}=t;if(a==="-"&&m===c.CHAR_CLASS&&l===g.RANGE)throw new Error("Invalid unescaped hyphen as the end value for a range");if(m===c.DEFAULT&&/^(?:[?*+]|\?\?)$/.test(a)||m===c.INTERVAL_QUANTIFIER&&a==="{")s+=E(a,{prefix:!1,postfix:i==="("&&a==="?"});else if(m===c.DEFAULT)le.test(a)?n=!0:a.startsWith("#")?o=!0:Re.test(a)?s+=E(a[1],{prefix:!1}):s+=E(a);else if(m===c.CHAR_CLASS&&a!=="["&&a!=="[^")if(ce.test(a)&&(p===g.DEFAULT||p===g.RANGE||p===g.Q_TOKEN))r=!0;else{if(p===g.INVALID_INCOMPLETE_TOKEN)throw new Error(`Invalid incomplete token in character class: "${a}"`);be.test(a)&&(p===g.DEFAULT||p===g.Q_TOKEN)?s+=E(a[1],{prefix:!1}):p===g.DEFAULT?s+=E(q(K(a))):s+=E(a)}else s+=E(a);n||r||o||(i=a,l=p)}return{transformed:s,runningContext:t}}function pe(e){let t=String.raw`\(\?:\)`;e=A(e,`(?:${t}){2,}`,"(?:)",d.DEFAULT);let n=I.replace(/\$/g,"\\$");return e=A(e,String.raw`(?:${t}(?=[)|.[$\\]|\((?!DEFINE)|$)|(?<=[()|.\]^>]|\\[bBdDfnrsStvwW]|\(\?(?:[:=!]|<[=!])|^)${t}(?![?*+{]))(?!${n})`,"",d.DEFAULT),e}var Ee=new RegExp(String.raw`(?<noncapturingStart>${U})|(?<capturingStart>\((?:\?<[^>]+>)?)|\\?.`,"gsu");function de(e,t){if(!_(e,"\\(\\?>",d.DEFAULT))return e;let n="(?>",r=`(?:(?=(${t.useEmulationGroups?I:""}`,o=[0],u=0,s=0,i=NaN,l;do{l=!1;let f=0,E=0,a=!1,m;for(Ee.lastIndex=Number.isNaN(i)?0:i+r.length;m=Ee.exec(e);){let{0:p,index:N,groups:{capturingStart:h,noncapturingStart:S}}=m;if(p==="[")f++;else if(f)p==="]"&&f--;else if(p===n&&!a)i=N,a=!0;else if(a&&S)E++;else if(h)a?E++:(u++,o.push(u+s));else if(p===")"&&a){if(!E){s++,e=`${e.slice(0,i)}${r}${e.slice(i+n.length,N)}))<$$${s+u}>)${e.slice(N+1)}`,l=!0;break}E--}}}while(l);return e=A(e,String.raw`\\(?<backrefNum>[1-9]\d*)|<\$\$(?<wrappedBackrefNum>\d+)>`,({0:f,groups:{backrefNum:E,wrappedBackrefNum:a}})=>{if(E){let m=+E;if(m>o.length-1)throw new Error(`Backref "${f}" greater than number of captures`);return`\\${o[m]}`}return`\\${a}`},d.DEFAULT),e}var ge=String.raw`(?:[?*+]|\{\d+(?:,\d*)?\})`,Fe=new RegExp(String.raw`
\\(?: \d+

@@ -62,5 +62,5 @@ | c[A-Za-z]

))?
| ${ge}(?<possessive>\+?)(?<invalid>[?*+\{]?)
| (?<q>${ge})(?<possessive>\+?)(?<invalid>[?*+\{]?)
| \\?.
`.replace(/\s+/g,""),"gsu");function me(e){if(!_(e,`${ge}+`,d.DEFAULT))return e;let t=[],n=null,r=null,o="",u=0,s="";for(let{0:i,index:l,groups:{possessive:f,invalid:p}}of e.matchAll(Fe)){if(i==="[")u||(r=l),u++;else if(i==="]")u?u--:r=null;else if(f&&o&&!o.startsWith("(")){let a=i.slice(0,-1);if(p)throw new Error(`Invalid quantifier "${i}"`);if(o===")"||o==="]"){let g=o===")"?n:r;if(g===null)throw new Error(`Invalid unmatched "${o}"`);let E=e.slice(g,l);s=`${e.slice(0,g)}(?>${E}${a})`}else s=`${e.slice(0,s.length-o.length)}(?>${o}${a})`;continue}else i[0]==="("?t.push(l):i===")"&&(n=t.length?t.pop():null);o=i,s+=i}return s}function Ne(e,t){let n=Ae(e,{includeContents:!0}),r=Pe(e,n,t.useEmulationGroups);return xe(r,n)}var ke=String.raw`\\g<(?<subroutineName>[^>&]+)>`,v=new RegExp(String.raw`
`.replace(/\s+/g,""),"gsu");function me(e){if(!_(e,`${ge}+`,d.DEFAULT))return e;let t=[],n=null,r=null,o="",u=0,s="";for(let{0:i,index:l,groups:{possessive:f,invalid:E,q:a}}of e.matchAll(Fe)){if(i==="[")u||(r=l),u++;else if(i==="]")u?u--:r=null;else if(f&&o&&!o.startsWith("(")){let m=i.slice(0,-1);if(E)throw new Error(`Invalid quantifier "${i}"`);if(/^\{\d+\}$/.test(a))s+=a;else if(o===")"||o==="]"){let p=o===")"?n:r;if(p===null)throw new Error(`Invalid unmatched "${o}"`);let N=e.slice(p,l);s=`${e.slice(0,p)}(?>${N}${m})`}else s=`${e.slice(0,s.length-o.length)}(?>${o}${m})`;continue}else i[0]==="("?t.push(l):i===")"&&(n=t.length?t.pop():null);o=i,s+=i}return s}function Ne(e,t){let n=Ae(e,{includeContents:!0}),r=Pe(e,n,t.useEmulationGroups);return xe(r,n)}var ke=String.raw`\\g<(?<subroutineName>[^>&]+)>`,v=new RegExp(String.raw`
${ke}

@@ -71,3 +71,3 @@ | (?<capturingStart>${b})

| \\?.
`.replace(/\s+/g,""),"gsu");function Pe(e,t,n){if(!_(e,"\\\\g<",d.DEFAULT))return e;let r=_(e,"\\\\(?:[1-9]|k<[^>]+>)",d.DEFAULT),o=r?`(${n?$:""}`:"(?:",u=new Map,s=[],i=[0],l=0,f=0,p=0,a=0,g=0,E=e,A;for(v.lastIndex=0;A=v.exec(E);){let{0:h,index:S,groups:{subroutineName:L,capturingStart:P,backrefNum:T,backrefName:y}}=A;if(h==="[")g++;else if(g)h==="]"&&g--;else if(L){if(!t.has(L))throw new Error(`Invalid named capture referenced by subroutine ${h}`);if(u.has(L))throw new Error(`Subroutine ${h} followed a recursive reference`);let w=t.get(L).contents,D=`${o}${w})`;r&&(p=0,f++),u.set(L,{unclosedGroupCount:Ge(D)}),s.push(L),E=Y(E,S,h,D),v.lastIndex-=h.length-o.length}else if(P)u.size?(r&&(p++,f++),h!=="("&&(E=Y(E,S,h,o),v.lastIndex-=h.length-o.length)):r&&(i.push(X(i)+1+f-a),a=f,l++);else if((T||y)&&u.size){let w=T?+T:t.get(y)?.groupNum,D=!1;for(let C of s){let O=t.get(C);if(w>=O.groupNum&&w<=O.groupNum+O.numCaptures){D=!0;break}}if(D){let C=t.get(X(s)),O=l+f-p,x=`\\k<$$b${w}s${O}r${C.groupNum}c${C.numCaptures}>`;E=Y(E,S,h,x),v.lastIndex+=x.length-h.length}}else if(h===")"&&u.size){let w=u.get(X(s));w.unclosedGroupCount--,w.unclosedGroupCount||u.delete(s.pop())}}return r&&(E=N(E,String.raw`\\(?:(?<bNum>[1-9]\d*)|k<\$\$b(?<bNumSub>\d+)s(?<subNum>\d+)r(?<refNum>\d+)c(?<refCaps>\d+)>)`,({0:h,groups:{bNum:S,bNumSub:L,subNum:P,refNum:T,refCaps:y}})=>{if(S){let x=+S;if(x>i.length-1)throw new Error(`Backref "${h}" greater than number of captures`);return`\\${i[x]}`}let w=+L,D=+P,C=+T,O=+y;return w<C||w>C+O?`\\${i[w]}`:`\\${D-C+w}`},d.DEFAULT)),E}var J=new RegExp(String.raw`${Q}|\(\?:\)|(?<invalid>\\?.)`,"gsu");function xe(e,t){let n=V(e,String.raw`\(\?\(DEFINE\)`,0,d.DEFAULT);if(!n)return e;let r=he(e,n);if(r.afterPos<e.length)throw new Error("DEFINE group allowed only at the end of a regex");if(r.afterPos>e.length)throw new Error("DEFINE group is unclosed");let o;for(J.lastIndex=0;o=J.exec(r.contents);){let{captureName:u,invalid:s}=o.groups;if(u){let i=he(r.contents,o),l;if(!t.get(u).isUnique)l=u;else{let f=Ae(i.contents);for(let p of f.keys())if(!t.get(p).isUnique){l=p;break}}if(l)throw new Error(`Duplicate group name "${l}" within DEFINE`);J.lastIndex=i.afterPos}else if(s)throw new Error("DEFINE group includes unsupported syntax at top level")}return e.slice(0,n.index)}function Ge(e){let t=0;return G(e,"\\(",()=>t++,d.DEFAULT),t}function Ke(e,t){let n=0,r=0,o;for(;o=V(e,b,r,d.DEFAULT);){let{0:u,index:s,groups:{captureName:i}}=o;if(n++,i===t)break;r=s+u.length}return n}function he(e,t){let n=t.index+t[0].length,r=W(e,n),o=n+r.length+1;return{contents:r,afterPos:o}}function Ae(e,{includeContents:t}={}){let n=new Map;return G(e,Q,({0:r,index:o,groups:{captureName:u}})=>{if(n.has(u))n.get(u).isUnique=!1;else{let s={isUnique:!0};if(t){let i=W(e,o+r.length);Object.assign(s,{contents:i,groupNum:Ke(e,u),numCaptures:k(i)})}n.set(u,s)}},d.DEFAULT),n}function X(e){return e[e.length-1]}function Y(e,t,n,r){return e.slice(0,t)+r+e.slice(t+n.length)}var Me="&!#%,:;<=>@`~",ve=new RegExp(String.raw`
`.replace(/\s+/g,""),"gsu");function Pe(e,t,n){if(!_(e,"\\\\g<",d.DEFAULT))return e;let r=_(e,"\\\\(?:[1-9]|k<[^>]+>)",d.DEFAULT),o=r?`(${n?I:""}`:"(?:",u=new Map,s=[],i=[0],l=0,f=0,E=0,a=0,m=0,p=e,N;for(v.lastIndex=0;N=v.exec(p);){let{0:h,index:S,groups:{subroutineName:$,capturingStart:P,backrefNum:T,backrefName:y}}=N;if(h==="[")m++;else if(m)h==="]"&&m--;else if($){if(!t.has($))throw new Error(`Invalid named capture referenced by subroutine ${h}`);if(u.has($))throw new Error(`Subroutine ${h} followed a recursive reference`);let w=t.get($).contents,D=`${o}${w})`;r&&(E=0,f++),u.set($,{unclosedGroupCount:Ge(D)}),s.push($),p=Y(p,S,h,D),v.lastIndex-=h.length-o.length}else if(P)u.size?(r&&(E++,f++),h!=="("&&(p=Y(p,S,h,o),v.lastIndex-=h.length-o.length)):r&&(i.push(X(i)+1+f-a),a=f,l++);else if((T||y)&&u.size){let w=T?+T:t.get(y)?.groupNum,D=!1;for(let C of s){let O=t.get(C);if(w>=O.groupNum&&w<=O.groupNum+O.numCaptures){D=!0;break}}if(D){let C=t.get(X(s)),O=l+f-E,x=`\\k<$$b${w}s${O}r${C.groupNum}c${C.numCaptures}>`;p=Y(p,S,h,x),v.lastIndex+=x.length-h.length}}else if(h===")"&&u.size){let w=u.get(X(s));w.unclosedGroupCount--,w.unclosedGroupCount||u.delete(s.pop())}}return r&&(p=A(p,String.raw`\\(?:(?<bNum>[1-9]\d*)|k<\$\$b(?<bNumSub>\d+)s(?<subNum>\d+)r(?<refNum>\d+)c(?<refCaps>\d+)>)`,({0:h,groups:{bNum:S,bNumSub:$,subNum:P,refNum:T,refCaps:y}})=>{if(S){let x=+S;if(x>i.length-1)throw new Error(`Backref "${h}" greater than number of captures`);return`\\${i[x]}`}let w=+$,D=+P,C=+T,O=+y;return w<C||w>C+O?`\\${i[w]}`:`\\${D-C+w}`},d.DEFAULT)),p}var J=new RegExp(String.raw`${Q}|\(\?:\)|(?<invalid>\\?.)`,"gsu");function xe(e,t){let n=V(e,String.raw`\(\?\(DEFINE\)`,0,d.DEFAULT);if(!n)return e;let r=he(e,n);if(r.afterPos<e.length)throw new Error("DEFINE group allowed only at the end of a regex");if(r.afterPos>e.length)throw new Error("DEFINE group is unclosed");let o;for(J.lastIndex=0;o=J.exec(r.contents);){let{captureName:u,invalid:s}=o.groups;if(u){let i=he(r.contents,o),l;if(!t.get(u).isUnique)l=u;else{let f=Ae(i.contents);for(let E of f.keys())if(!t.get(E).isUnique){l=E;break}}if(l)throw new Error(`Duplicate group name "${l}" within DEFINE`);J.lastIndex=i.afterPos}else if(s)throw new Error("DEFINE group includes unsupported syntax at top level")}return e.slice(0,n.index)}function Ge(e){let t=0;return G(e,"\\(",()=>t++,d.DEFAULT),t}function Me(e,t){let n=0,r=0,o;for(;o=V(e,b,r,d.DEFAULT);){let{0:u,index:s,groups:{captureName:i}}=o;if(n++,i===t)break;r=s+u.length}return n}function he(e,t){let n=t.index+t[0].length,r=W(e,n),o=n+r.length+1;return{contents:r,afterPos:o}}function Ae(e,{includeContents:t}={}){let n=new Map;return G(e,Q,({0:r,index:o,groups:{captureName:u}})=>{if(n.has(u))n.get(u).isUnique=!1;else{let s={isUnique:!0};if(t){let i=W(e,o+r.length);Object.assign(s,{contents:i,groupNum:Me(e,u),numCaptures:k(i)})}n.set(u,s)}},d.DEFAULT),n}function X(e){return e[e.length-1]}function Y(e,t,n,r){return e.slice(0,t)+r+e.slice(t+n.length)}var Ke="&!#%,:;<=>@`~",ve=new RegExp(String.raw`
\[\^?-?

@@ -77,5 +77,5 @@ | --?\]

| --
| \\(?<vOnlyEscape>[${Me}])
| \\(?<vOnlyEscape>[${Ke}])
| \\[pPu]\{[^}]+\}
| \\?.
`.replace(/\s+/g,""),"gsu");function we(e){let t='Invalid unescaped "-" in character class',n=!1,r="";for(let{0:o,groups:{dp:u,vOnlyEscape:s}}of e.matchAll(ve)){if(o[0]==="["){if(n)throw new Error("Invalid nested character class when flag v not supported; possibly from interpolation");if(o.endsWith("-"))throw new Error(t);n=!0}else if(o.endsWith("]")){if(o[0]==="-")throw new Error(t);n=!1}else if(n){if(o==="&&"||o==="--")throw new Error(`Invalid set operator "${o}" when flag v not supported`);if(u)throw new Error(`Invalid double punctuator "${o}", reserved by flag v`);if("(){}/|".includes(o))throw new Error(`Invalid unescaped "${o}" in character class`);if(s){r+=s;continue}}r+=o}return r}var ye=(e,...t)=>{if(Array.isArray(e?.raw))return ee({},e,...t);if((typeof e=="string"||e===void 0)&&!t.length)return ee.bind(null,{flags:e});if({}.toString.call(e)==="[object Object]"&&!t.length)return ee.bind(null,e);throw new Error(`Unexpected arguments: ${JSON.stringify([e,...t])}`)},ee=(e,t,...n)=>{let{flags:r="",subclass:o=!1,plugins:u=[],unicodeSetsPlugin:s=we,disable:i={},force:l={}}=e;if(/[vu]/.test(r))throw new Error("Flags v/u cannot be explicitly added");let f=l.v||(i.v?!1:oe),p=(f?"v":"u")+r;i.x||({template:t,substitutions:n}=Z(t,n,fe)),i.n||({template:t,substitutions:n}=Z(t,n,ae));let a=0,g="",E;if(t.raw.forEach((A,h)=>{let S=!!(t.raw[h]||t.raw[h+1]);a+=k(A),g+=M(A,d.CHAR_CLASS),E=F(g,E);let{regexContext:L,charClassContext:P}=E;if(h<t.raw.length-1){let T=n[h];g+=Ve(T,r,L,P,S,a),T instanceof RegExp?a+=k(T.source):T instanceof I&&(a+=k(String(T)))}}),[...u,...i.atomic?[]:[me,de],...i.subroutines?[]:[Ne],...i.x?[]:[pe],...f||!s?[]:[s]].forEach(A=>g=A(g,{flags:p,useEmulationGroups:o})),o){let A=Qe(g);return new te(A.expression,p,{emulationGroups:A.emulationGroups})}return new RegExp(g,p)},te=class e extends RegExp{#e;constructor(t,n,r){super(t,n),r?this.#e=r.emulationGroups:t instanceof e&&(this.#e=t.#e)}exec(t){let n=RegExp.prototype.exec.call(this,t);if(!n||!this.#e)return n;let r=[...n];n.length=1;for(let o=1;o<r.length;o++)this.#e[o]||n.push(r[o]);return n}};function Ve(e,t,n,r,o,u){if(e instanceof RegExp&&n!==c.DEFAULT)throw new Error("Cannot interpolate a RegExp at this position because the syntax context does not match");if(n===c.INVALID_INCOMPLETE_TOKEN||r===m.INVALID_INCOMPLETE_TOKEN)throw new Error("Interpolation preceded by invalid incomplete token");let s=e instanceof I,i="";if(!(e instanceof RegExp)){e=String(e),s||(i=B(e,n===c.CHAR_CLASS?d.CHAR_CLASS:d.DEFAULT));let l=ie(i||e,n,r);if(l)throw new Error(`Unescaped stray "${l}" in the interpolated value would have side effects outside it`)}if(n===c.ENCLOSED_TOKEN||n===c.INTERVAL_QUANTIFIER||n===c.GROUP_NAME||r===m.ENCLOSED_TOKEN||r===m.Q_TOKEN)return s?String(e):i;if(n===c.CHAR_CLASS){if(s){if(_(String(e),"^-|^&&|-$|&&$"))throw new Error("Cannot use range or set operator at boundary of interpolated pattern; move the operation into the pattern or the operator outside of it");let l=se(H(e));return z(e)?`[${l}]`:M(l)}return z(i)?`[${i}]`:i}if(e instanceof RegExp){let l=je(e,t),f=ue(l.value,u);return l.usedModifier?f:`(?:${f})`}return s?`(?:${e})`:o?`(?:${i})`:i}function je(e,t){let n={i:null,m:null,s:null},r="\\n\\r\\u2028\\u2029",o=e.source;if(e.ignoreCase!==t.includes("i"))if(K)n.i=e.ignoreCase;else throw new Error("Pattern modifiers not supported, so the value of flag i on the interpolated RegExp must match the outer regex");if(e.dotAll!==t.includes("s")&&(K?n.s=e.dotAll:o=N(o,"\\.",e.dotAll?"[^]":`[^${r}]`,d.DEFAULT)),e.multiline!==t.includes("m")&&(K?n.m=e.multiline:(o=N(o,"\\^",e.multiline?`(?<=^|[${r}])`:"(?<![^])",d.DEFAULT),o=N(o,"\\$",e.multiline?`(?=$|[${r}])`:"(?![^])",d.DEFAULT))),K){let u=Object.keys(n),s=u.filter(l=>n[l]===!0).join(""),i=u.filter(l=>n[l]===!1).join("");if(i&&(s+=`-${i}`),s)return{value:`(?${s}:${o})`,usedModifier:!0}}return{value:o}}function Qe(e){let t=$.replace(/\$/g,"\\$"),n=[!1];return e=N(e,`(?:${b})${t}`,({0:r})=>r.endsWith($)?(n.push(!0),r.slice(0,-$.length)):(n.push(!1),r),d.DEFAULT),{emulationGroups:n,expression:e}}return Ce(He);})();
`.replace(/\s+/g,""),"gsu");function we(e){let t='Invalid unescaped "-" in character class',n=!1,r="";for(let{0:o,groups:{dp:u,vOnlyEscape:s}}of e.matchAll(ve)){if(o[0]==="["){if(n)throw new Error("Invalid nested character class when flag v not supported; possibly from interpolation");if(o.endsWith("-"))throw new Error(t);n=!0}else if(o.endsWith("]")){if(o[0]==="-")throw new Error(t);n=!1}else if(n){if(o==="&&"||o==="--")throw new Error(`Invalid set operator "${o}" when flag v not supported`);if(u)throw new Error(`Invalid double punctuator "${o}", reserved by flag v`);if("(){}/|".includes(o))throw new Error(`Invalid unescaped "${o}" in character class`);if(s){r+=s;continue}}r+=o}return r}var ye=(e,...t)=>{if(Array.isArray(e?.raw))return ee({},e,...t);if((typeof e=="string"||e===void 0)&&!t.length)return ee.bind(null,{flags:e});if({}.toString.call(e)==="[object Object]"&&!t.length)return ee.bind(null,e);throw new Error(`Unexpected arguments: ${JSON.stringify([e,...t])}`)},ee=(e,t,...n)=>{let{flags:r="",subclass:o=!1,plugins:u=[],unicodeSetsPlugin:s=we,disable:i={},force:l={}}=e;if(/[vu]/.test(r))throw new Error("Flags v/u cannot be explicitly added");let f=l.v||(i.v?!1:oe),E=(f?"v":"u")+r;i.x||({template:t,substitutions:n}=Z(t,n,fe)),i.n||({template:t,substitutions:n}=Z(t,n,ae));let a=0,m="",p;if(t.raw.forEach((N,h)=>{let S=!!(t.raw[h]||t.raw[h+1]);a+=k(N),m+=K(N,d.CHAR_CLASS),p=F(m,p);let{regexContext:$,charClassContext:P}=p;if(h<t.raw.length-1){let T=n[h];m+=Ve(T,r,$,P,S,a),T instanceof RegExp?a+=k(T.source):T instanceof L&&(a+=k(String(T)))}}),[...u,...i.subroutines?[]:[Ne],...i.atomic?[]:[me,de],...i.x?[]:[pe],...f||!s?[]:[s]].forEach(N=>m=N(m,{flags:E,useEmulationGroups:o})),o){let N=Qe(m);return new te(N.expression,E,{captureMap:N.captureMap})}return new RegExp(m,E)},te=class e extends RegExp{#e;constructor(t,n,r){super(t,n),r?this.#e=r.captureMap:t instanceof e&&(this.#e=t.#e)}exec(t){let n=RegExp.prototype.exec.call(this,t);if(!n||!this.#e)return n;let r=[...n];n.length=1;for(let o=1;o<r.length;o++)this.#e[o]&&n.push(r[o]);return n}};function Ve(e,t,n,r,o,u){if(e instanceof RegExp&&n!==c.DEFAULT)throw new Error("Cannot interpolate a RegExp at this position because the syntax context does not match");if(n===c.INVALID_INCOMPLETE_TOKEN||r===g.INVALID_INCOMPLETE_TOKEN)throw new Error("Interpolation preceded by invalid incomplete token");let s=e instanceof L,i="";if(!(e instanceof RegExp)){e=String(e),s||(i=B(e,n===c.CHAR_CLASS?d.CHAR_CLASS:d.DEFAULT));let l=ie(i||e,n,r);if(l)throw new Error(`Unescaped stray "${l}" in the interpolated value would have side effects outside it`)}if(n===c.ENCLOSED_TOKEN||n===c.INTERVAL_QUANTIFIER||n===c.GROUP_NAME||r===g.ENCLOSED_TOKEN||r===g.Q_TOKEN)return s?String(e):i;if(n===c.CHAR_CLASS){if(s){if(_(String(e),"^-|^&&|-$|&&$"))throw new Error("Cannot use range or set operator at boundary of interpolated pattern; move the operation into the pattern or the operator outside of it");let l=se(q(e));return z(e)?`[${l}]`:K(l)}return z(i)?`[${i}]`:i}if(e instanceof RegExp){let l=je(e,t),f=ue(l.value,u);return l.usedModifier?f:`(?:${f})`}return s?`(?:${e})`:o?`(?:${i})`:i}function je(e,t){let n={i:null,m:null,s:null},r="\\n\\r\\u2028\\u2029",o=e.source;if(e.ignoreCase!==t.includes("i"))if(M)n.i=e.ignoreCase;else throw new Error("Pattern modifiers not supported, so the value of flag i on the interpolated RegExp must match the outer regex");if(e.dotAll!==t.includes("s")&&(M?n.s=e.dotAll:o=A(o,"\\.",e.dotAll?"[^]":`[^${r}]`,d.DEFAULT)),e.multiline!==t.includes("m")&&(M?n.m=e.multiline:(o=A(o,"\\^",e.multiline?`(?<=^|[${r}])`:"(?<![^])",d.DEFAULT),o=A(o,"\\$",e.multiline?`(?=$|[${r}])`:"(?![^])",d.DEFAULT))),M){let u=Object.keys(n),s=u.filter(l=>n[l]===!0).join(""),i=u.filter(l=>n[l]===!1).join("");if(i&&(s+=`-${i}`),s)return{value:`(?${s}:${o})`,usedModifier:!0}}return{value:o}}function Qe(e){let t=I.replace(/\$/g,"\\$"),n=[!0];return e=A(e,`(?:${b})(?<mark>${t})?`,({0:r,groups:{mark:o}})=>o?(n.push(!1),r.slice(0,-I.length)):(n.push(!0),r),d.DEFAULT),{captureMap:n,expression:e}}return Ce(qe);})();
{
"name": "regex",
"version": "4.1.0",
"version": "4.1.1",
"description": "Regex template tag with extended syntax, context-aware interpolation, and always-on best practices",

@@ -5,0 +5,0 @@ "author": "Steven Levithan",

@@ -17,3 +17,3 @@ <div align="center">

Highlights include support for free spacing and comments, atomic groups via `(?>…)` that can help you avoid [ReDoS](https://en.wikipedia.org/wiki/ReDoS), subroutines via `\g<name>` and subroutine definition groups via `(?(DEFINE)…)` that enable powerful subpattern composition, and context-aware interpolation of regexes, escaped strings, and partial patterns.
Highlights include support for free spacing and comments, atomic groups via `(?>…)` and possessive quantifiers (e.g. `++`) that can help you avoid [ReDoS](https://en.wikipedia.org/wiki/ReDoS), subroutines via `\g<name>` and subroutine definition groups via `(?(DEFINE)…)` that enable powerful subpattern composition, and context-aware interpolation of regexes, escaped strings, and partial patterns.

@@ -122,3 +122,3 @@ With the `regex` library, JavaScript steps up as one of the best regex flavors alongside PCRE and Perl, possibly surpassing C++, Java, .NET, Python, and Ruby.

<script type="module">
import {regex, pattern} from 'https://cdn.jsdelivr.net/npm/regex@4.1.0/+esm';
import {regex, pattern} from 'https://cdn.jsdelivr.net/npm/regex@4.1.1/+esm';
// …

@@ -132,3 +132,3 @@ </script>

```html
<script src="https://cdn.jsdelivr.net/npm/regex@4.1.0/dist/regex.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/regex@4.1.1/dist/regex.min.js"></script>
<script>

@@ -219,3 +219,3 @@ const {regex, pattern} = Regex;

> Possessive quantifiers are syntactic sugar for [atomic groups](#atomic-groups) when their contents are a single repeated item.
> Possessive quantifiers are syntactic sugar for [atomic groups](#atomic-groups) when their contents are a single repeated item (token, character class, or group).

@@ -235,2 +235,4 @@ Like atomic groups, possessive quantifiers are mostly useful for performance and preventing ReDoS, but they can also be used to eliminate certain matches. For example, `` regex`a++.` `` matches one or more `a` followed by a character other than `a`. Unlike `/a+./`, it won't match a sequence of only `a` characters like `'aaa'`. The possessive `++` doesn't give back any of the `a`s it matched, so in this case there's nothing left for the `.` to match.

> Fixed repetition quantifiers behave the same whether they're greedy `{2}`, lazy `{2}?`, or possessive `{2}+`.
> [!NOTE]

@@ -237,0 +239,0 @@ > Possessive quantifiers are supported in many other regex flavors. There's a [proposal](https://github.com/tc39/proposal-regexp-atomic-operators) to add them to JavaScript.

@@ -86,6 +86,6 @@ export type InterpolatedValue = string | RegExp | Pattern | number;

@param {string} [flags]
@param {{emulationGroups: Array<boolean>;}} [data]
@param {{captureMap: Array<boolean>;}} [data]
*/
constructor(expression: string | WrappedRegex, flags?: string, data?: {
emulationGroups: Array<boolean>;
captureMap: Array<boolean>;
});

@@ -92,0 +92,0 @@ #private;

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc