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.3 to 4.2.0

34

dist/regex.min.js

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

var Regex=(()=>{var H=Object.defineProperty;var Se=Object.getOwnPropertyDescriptor;var Te=Object.getOwnPropertyNames;var $e=Object.prototype.hasOwnProperty;var Ie=(e,t)=>{for(var n in t)H(e,n,{get:t[n],enumerable:!0})},Ce=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Te(t))!$e.call(e,o)&&o!==n&&H(e,o,{get:()=>t[o],enumerable:!(r=Se(t,o))||r.enumerable});return e};var Le=e=>Ce(H({},"__esModule",{value:!0}),e);var qe={};Ie(qe,{pattern:()=>Q,regex:()=>ve});var g=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:c}}=i;if(!c&&(!r||r===g.DEFAULT==!u)){n instanceof Function?s+=n(i):s+=n;continue}l==="["?u++:l==="]"&&u&&u--,s+=l}return s}function x(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===g.DEFAULT==!u))return s;i==="["?u++:i==="]"&&u&&u--,o.lastIndex==s.index&&o.lastIndex++}return null}function V(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 Q(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 f={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"},d={DEFAULT:"CC_DEFAULT",RANGE:"CC_RANGE",ENCLOSED_TOKEN:"CC_ENCLOSED_TOKEN",Q_TOKEN:"CC_Q_TOKEN",INVALID_INCOMPLETE_TOKEN:"CC_INVALID_INCOMPLETE_TOKEN"},G=(()=>{try{new RegExp("(?i:)")}catch{return!1}return!0})(),se=(()=>{try{new RegExp("","v")}catch{return!1}return!0})(),R="&!#$%*+,.:;<=>?@^`~",C="$E$",j=String.raw`\(\?<(?![=!])(?<captureName>[^>]+)>`,D=String.raw`\((?!\?)(?!(?<=\(\?\()DEFINE\))|${j}`,b=String.raw`\(\?(?:[:=!>A-Za-z\-]|<[=!]|\(DEFINE\))`;function B(e,t){return t===g.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 ie(e){return e.replace(/^\^/,"\\^^")}function M(e,t){return A(e,String.raw`\\0(?!\d)`,"\\u{0}",t)}function re(e,t,n){let r=0;for(let[o]of e.matchAll(new RegExp(`[${B(t+n,g.CHAR_CLASS)}]`,"g")))if(r+=o===t?1:-1,r<0)return n;return r>0?t:""}function ue(e,t,n){let r=e.replace(/\\./gsu,"");if(r.endsWith("\\"))return"\\";if(t===f.DEFAULT)return re(r,"(",")");if(t===f.CHAR_CLASS&&!(n===d.ENCLOSED_TOKEN||n===d.Q_TOKEN))return re(r,"[","]");if(t===f.ENCLOSED_TOKEN||t===f.INTERVAL_QUANTIFIER||n===d.ENCLOSED_TOKEN||n===d.Q_TOKEN){if(r.includes("}"))return"}"}else if(t===f.GROUP_NAME&&r.includes(">"))return">";return""}var oe=new RegExp(String.raw`
var Regex=(()=>{var H=Object.defineProperty;var Ce=Object.getOwnPropertyDescriptor;var Ie=Object.getOwnPropertyNames;var Le=Object.prototype.hasOwnProperty;var _e=(e,t)=>{for(var n in t)H(e,n,{get:t[n],enumerable:!0})},be=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Ie(t))!Le.call(e,o)&&o!==n&&H(e,o,{get:()=>t[o],enumerable:!(r=Ce(t,o))||r.enumerable});return e};var Oe=e=>be(H({},"__esModule",{value:!0}),e);var ze={};_e(ze,{pattern:()=>V,processRegex:()=>qe,regex:()=>je});var E=Object.freeze({DEFAULT:"DEFAULT",CHAR_CLASS:"CHAR_CLASS"});function N(e,t,n,r){let o=new RegExp(String.raw`${t}|(?<$skip>\[\^?|\\?.)`,"gsu"),i=[!1],s=0,a="";for(let u of e.matchAll(o)){let{0:c,groups:{$skip:p}}=u;if(!p&&(!r||r===E.DEFAULT==!s)){n instanceof Function?a+=n(u,{context:s?E.CHAR_CLASS:E.DEFAULT,negated:i[i.length-1]}):a+=n;continue}c[0]==="["?(s++,i.push(c[1]==="^")):c==="]"&&s&&(s--,i.pop()),a+=c}return a}function k(e,t,n,r){N(e,t,n,r)}function y(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 i=0,s;for(;s=o.exec(e);){let{0:a,groups:{$skip:u}}=s;if(!u&&(!r||r===E.DEFAULT==!i))return s;a==="["?i++:a==="]"&&i&&i--,o.lastIndex==s.index&&o.lastIndex++}return null}function v(e,t,n){return!!y(e,t,0,n)}function W(e,t){let n=/\\?./gsu;n.lastIndex=t;let r=e.length,o=0,i=1,s;for(;s=n.exec(e);){let[a]=s;if(a==="[")o++;else if(o)a==="]"&&o--;else if(a==="(")i++;else if(a===")"&&(i--,!i)){r=s.index;break}}return e.slice(t,r)}var $=class{#e;constructor(t){this.#e=t}toString(){return String(this.#e)}};function V(e,...t){if(Array.isArray(e?.raw))return new $(e.raw.flatMap((n,r)=>r<e.raw.length-1?[n,t[r]]:n).join(""));if(!t.length)return new $(e??"");throw new Error(`Unexpected arguments: ${JSON.stringify([e,...t])}`)}var f={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"},d={DEFAULT:"CC_DEFAULT",RANGE:"CC_RANGE",ENCLOSED_TOKEN:"CC_ENCLOSED_TOKEN",Q_TOKEN:"CC_Q_TOKEN",INVALID_INCOMPLETE_TOKEN:"CC_INVALID_INCOMPLETE_TOKEN"},x=(()=>{try{new RegExp("(?i:)")}catch{return!1}return!0})(),oe=(()=>{try{new RegExp("","v")}catch{return!1}return!0})(),b="&!#$%*+,.:;<=>?@^`~",C="$E$",Q=String.raw`\(\?<(?![=!])(?<captureName>[^>]+)>`,O=String.raw`\((?!\?)(?!(?<=\(\?\()DEFINE\))|${Q}`,R=String.raw`\(\?(?:[:=!>A-Za-z\-]|<[=!]|\(DEFINE\))`;function B(e,t){return t===E.CHAR_CLASS?e.replace(new RegExp(String.raw`[()\[\]{}|\\/\-${b}]`,"g"),"\\$&"):e.replace(/[()\[\]{}|\\^$*+?.]/g,"\\$&")}function j(e){return e.replace(new RegExp(`^([${b}])(?!\\1)`),(t,n,r)=>`\\${t}${r+1===e.length?"":t}`)}function se(e){return e.replace(/^\^/,"\\^^")}function G(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,E.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===f.DEFAULT)return ne(r,"(",")");if(t===f.CHAR_CLASS&&!(n===d.ENCLOSED_TOKEN||n===d.Q_TOKEN))return ne(r,"[","]");if(t===f.ENCLOSED_TOKEN||t===f.INTERVAL_QUANTIFIER||n===d.ENCLOSED_TOKEN||n===d.Q_TOKEN){if(r.includes("}"))return"}"}else if(t===f.GROUP_NAME&&r.includes(">"))return">";return""}var re=new RegExp(String.raw`
(?<groupN>\(\?<(?![=!])|\\[gk]<)

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

| \\?.
`.replace(/\s+/g,""),"gsu");function U(e,{regexContext:t=f.DEFAULT,charClassContext:n=d.DEFAULT,charClassDepth:r=0,lastPos:o=0}={}){oe.lastIndex=o;let u;for(;u=oe.exec(e);){let{0:s,groups:{groupN:i,enclosedT:l,qT:c,intervalQ:p,incompleteT:a}}=u;s==="["?(r++,t=f.CHAR_CLASS,n=d.DEFAULT):s==="]"&&t===f.CHAR_CLASS?(r&&r--,r||(t=f.DEFAULT),n=d.DEFAULT):t===f.CHAR_CLASS?a?n=d.INVALID_INCOMPLETE_TOKEN:s==="-"?n=d.RANGE:l?n=d.ENCLOSED_TOKEN:c?n=d.Q_TOKEN:(s==="}"&&(n===d.ENCLOSED_TOKEN||n===d.Q_TOKEN)||n===d.INVALID_INCOMPLETE_TOKEN||n===d.RANGE)&&(n=d.DEFAULT):a?t=f.INVALID_INCOMPLETE_TOKEN:i?t=f.GROUP_NAME:l?t=f.ENCLOSED_TOKEN:p?t=f.INTERVAL_QUANTIFIER:(s===">"&&t===f.GROUP_NAME||s==="}"&&(t===f.ENCLOSED_TOKEN||t===f.INTERVAL_QUANTIFIER)||t===f.INVALID_INCOMPLETE_TOKEN)&&(t=f.DEFAULT)}return{regexContext:t,charClassContext:n,charClassDepth:r,lastPos:e.length}}function F(e){let t=0;return x(e,D,()=>t++,g.DEFAULT),t}function ae(e,t){return A(e,String.raw`\\(?<num>[1-9]\d*)`,({groups:{num:n}})=>`\\${+n+t}`,g.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("|"),Oe=new RegExp(String.raw`
`.replace(/\s+/g,""),"gsu");function D(e,{regexContext:t=f.DEFAULT,charClassContext:n=d.DEFAULT,charClassDepth:r=0,lastPos:o=0}={}){re.lastIndex=o;let i;for(;i=re.exec(e);){let{0:s,groups:{groupN:a,enclosedT:u,qT:c,intervalQ:p,incompleteT:g}}=i;s==="["?(r++,t=f.CHAR_CLASS,n=d.DEFAULT):s==="]"&&t===f.CHAR_CLASS?(r&&r--,r||(t=f.DEFAULT),n=d.DEFAULT):t===f.CHAR_CLASS?g?n=d.INVALID_INCOMPLETE_TOKEN:s==="-"?n=d.RANGE:u?n=d.ENCLOSED_TOKEN:c?n=d.Q_TOKEN:(s==="}"&&(n===d.ENCLOSED_TOKEN||n===d.Q_TOKEN)||n===d.INVALID_INCOMPLETE_TOKEN||n===d.RANGE)&&(n=d.DEFAULT):g?t=f.INVALID_INCOMPLETE_TOKEN:a?t=f.GROUP_NAME:u?t=f.ENCLOSED_TOKEN:p?t=f.INTERVAL_QUANTIFIER:(s===">"&&t===f.GROUP_NAME||s==="}"&&(t===f.ENCLOSED_TOKEN||t===f.INTERVAL_QUANTIFIER)||t===f.INVALID_INCOMPLETE_TOKEN)&&(t=f.DEFAULT)}return{regexContext:t,charClassContext:n,charClassDepth:r,lastPos:e.length}}function U(e){let t=0;return k(e,O,()=>t++,E.DEFAULT),t}function ae(e,t){return N(e,String.raw`\\(?<num>[1-9]\d*)`,({groups:{num:n}})=>`\\${+n+t}`,E.DEFAULT)}var Re=["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]
| p\{(?<pStrProp>${_e})\}
| p\{(?<pStrProp>${Re})\}
| [pP]\{[^\}]+\}

@@ -27,8 +27,8 @@ | (?<qStrProp>q)

| .
`.replace(/\s+/g,""),"gsu");function z(e){let t=!1,n;for(let{0:r,groups:o}of e.matchAll(Oe)){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 c=t[i];if(c instanceof I){let p=n(c,{...u,lastPos:0});o.push(Q(p.transformed)),u=p.runningContext}else o.push(c)}}),{template:r,substitutions:o}}var Re=new RegExp(String.raw`
${b}
`.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 ue(e,t,n,r){let o={raw:[]},i=[],s;return e.raw.forEach((a,u)=>{let c=n(a,{...s,lastPos:0},r);if(o.raw.push(c.transformed),s=c.runningContext,u<e.raw.length-1){let p=t[u];if(p instanceof $){let g=n(p,{...s,lastPos:0},r);i.push(V(g.transformed)),s=g.runningContext}else i.push(p)}}),{template:o,substitutions:i}}var Ue=new RegExp(String.raw`
${R}
| \(\?<
| (?<backrefNum>\\[1-9]\d*)
| \\?.
`.replace(/\s+/g,""),"gsu");function le(e,t){e=String(e);let n="",r="";for(let{0:o,groups:{backrefNum:u}}of e.matchAll(Re)){n+=o,t=U(n,t);let{regexContext:s}=t;if(s===f.DEFAULT)if(o==="(")r+="(?:";else{if(u)throw new Error(`Invalid decimal escape "${o}" with implicit flag n; replace with named backreference`);r+=o}else r+=o}return{transformed:r,runningContext:t}}var ce=/^\s$/,De=/^\\[\s#]$/,J=/^[ \t]$/,be=/^\\[ \t]$/,Ue=new RegExp(String.raw`
`.replace(/\s+/g,""),"gsu");function le(e,t){e=String(e);let n="",r="";for(let{0:o,groups:{backrefNum:i}}of e.matchAll(Ue)){n+=o,t=D(n,t);let{regexContext:s}=t;if(s===f.DEFAULT)if(o==="(")r+="(?:";else{if(i)throw new Error(`Invalid decimal escape "${o}" with implicit flag n; replace with named backreference`);r+=o}else r+=o}return{transformed:r,runningContext:t}}var ce=/^\s$/,Fe=/^\\[\s#]$/,Z=/^[ \t]$/,Pe=/^\\[ \t]$/,ke=new RegExp(String.raw`
\\(?: [gk]<

@@ -42,9 +42,9 @@ | [pPu]\{

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

@@ -64,17 +64,17 @@ | c[A-Za-z]

| \\?.
`.replace(/\s+/g,""),"gsu");function me(e){if(!new RegExp(`${ge}\\+`).test(e))return e;let t=[],n=null,r=null,o="",u=0,s="";for(let{0:i,index:l,groups:{q:c,qMod:p,invalidQ:a}}of e.matchAll(Fe)){if(i==="[")u||(r=l),u++;else if(i==="]")u?u--:r=null;else if(p==="+"&&o&&!o.startsWith("(")){if(a)throw new Error(`Invalid quantifier "${i}"`);if(/^\{\d+\}$/.test(c))s+=c;else if(o===")"||o==="]"){let m=o===")"?n:r;if(m===null)throw new Error(`Invalid unmatched "${o}"`);let E=e.slice(m,l);s=`${e.slice(0,m)}(?>${E}${c})`}else s=`${e.slice(0,s.length-o.length)}(?>${o}${c})`;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>[^>&]+)>`,K=new RegExp(String.raw`
${ke}
| (?<capturingStart>${D})
`.replace(/\s+/g,""),"gsu");function me(e){if(!new RegExp(`${ge}\\+`).test(e))return e;let t=[],n=null,r=null,o="",i=0,s="";for(let{0:a,index:u,groups:{q:c,qMod:p,invalidQ:g}}of e.matchAll(xe)){if(a==="[")i||(r=u),i++;else if(a==="]")i?i--:r=null;else if(p==="+"&&o&&!o.startsWith("(")){if(g)throw new Error(`Invalid quantifier "${a}"`);if(/^\{\d+\}$/.test(c))s+=c;else if(o===")"||o==="]"){let l=o===")"?n:r;if(l===null)throw new Error(`Invalid unmatched "${o}"`);let m=e.slice(l,u);s=`${e.slice(0,l)}(?>${m}${c})`}else s=`${e.slice(0,s.length-o.length)}(?>${o}${c})`;continue}else a[0]==="("?t.push(u):a===")"&&(n=t.length?t.pop():null);o=a,s+=a}return s}function Ne(e,t){let n=Ae(e,{includeContents:!0}),r=Me(e,n,t.useEmulationGroups);return Ke(r,n)}var Ge=String.raw`\\g<(?<subroutineName>[^>&]+)>`,M=new RegExp(String.raw`
${Ge}
| (?<capturingStart>${O})
| \\(?<backrefNum>[1-9]\d*)
| \\k<(?<backrefName>[^>]+)>
| \\?.
`.replace(/\s+/g,""),"gsu");function Pe(e,t,n){if(!/\\g</.test(e))return e;let r=V(e,"\\\\(?:[1-9]|k<[^>]+>)",g.DEFAULT),o=r?`(${n?C:""}`:"(?:",u=new Map,s=[],i=[0],l=0,c=0,p=0,a=0,m=0,E=e,h;for(K.lastIndex=0;h=K.exec(E);){let{0:N,index:w,groups:{subroutineName:$,capturingStart:k,backrefNum:T,backrefName:y}}=h;if(N==="[")m++;else if(m)N==="]"&&m--;else if($){if(!t.has($))throw new Error(`Invalid named capture referenced by subroutine ${N}`);if(u.has($))throw new Error(`Subroutine ${N} followed a recursive reference`);let S=t.get($).contents,_=`${o}${S})`;r&&(p=0,c++),u.set($,{unclosedGroupCount:Ge(_)}),s.push($),E=ee(E,w,N,_),K.lastIndex-=N.length-o.length}else if(k)u.size?(r&&(p++,c++),N!=="("&&(E=ee(E,w,N,o),K.lastIndex-=N.length-o.length)):r&&(i.push(Y(i)+1+c-a),a=c,l++);else if((T||y)&&u.size){let S=T?+T:t.get(y)?.groupNum,_=!1;for(let L of s){let O=t.get(L);if(S>=O.groupNum&&S<=O.groupNum+O.numCaptures){_=!0;break}}if(_){let L=t.get(Y(s)),O=l+c-p,P=`\\k<$$b${S}s${O}r${L.groupNum}c${L.numCaptures}>`;E=ee(E,w,N,P),K.lastIndex+=P.length-N.length}}else if(N===")"&&u.size){let S=u.get(Y(s));S.unclosedGroupCount--,S.unclosedGroupCount||u.delete(s.pop())}}return r&&(E=A(E,String.raw`\\(?:(?<bNum>[1-9]\d*)|k<\$\$b(?<bNumSub>\d+)s(?<subNum>\d+)r(?<refNum>\d+)c(?<refCaps>\d+)>)`,({0:N,groups:{bNum:w,bNumSub:$,subNum:k,refNum:T,refCaps:y}})=>{if(w){let P=+w;if(P>i.length-1)throw new Error(`Backref "${N}" greater than number of captures`);return`\\${i[P]}`}let S=+$,_=+k,L=+T,O=+y;return S<L||S>L+O?`\\${i[S]}`:`\\${_-L+S}`},g.DEFAULT)),E}var X=new RegExp(String.raw`${j}|\(\?:\)|(?<invalid>\\?.)`,"gsu");function xe(e,t){let n=v(e,String.raw`\(\?\(DEFINE\)`,0,g.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(X.lastIndex=0;o=X.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 c=Ae(i.contents);for(let p of c.keys())if(!t.get(p).isUnique){l=p;break}}if(l)throw new Error(`Duplicate group name "${l}" within DEFINE`);X.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 x(e,"\\(",()=>t++,g.DEFAULT),t}function Me(e,t){let n=0,r=0,o;for(;o=v(e,D,r,g.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 x(e,j,({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:F(i)})}n.set(u,s)}},g.DEFAULT),n}function Y(e){return e[e.length-1]}function ee(e,t,n,r){return e.slice(0,t)+r+e.slice(t+n.length)}var Ke="&!#%,:;<=>@`~",ye=new RegExp(String.raw`
`.replace(/\s+/g,""),"gsu");function Me(e,t,n){if(!/\\g</.test(e))return e;let r=v(e,"\\\\(?:[1-9]|k<[^>]+>)",E.DEFAULT),o=r?`(${n?C:""}`:"(?:",i=new Map,s=[],a=[0],u=0,c=0,p=0,g=0,l=0,m=e,A;for(M.lastIndex=0;A=M.exec(m);){let{0:h,index:T,groups:{subroutineName:S,capturingStart:q,backrefNum:F,backrefName:K}}=A;if(h==="[")l++;else if(l)h==="]"&&l--;else if(S){if(!t.has(S))throw new Error(`Invalid named capture referenced by subroutine ${h}`);if(i.has(S))throw new Error(`Subroutine ${h} followed a recursive reference`);let w=t.get(S).contents,L=`${o}${w})`;r&&(p=0,c++),i.set(S,{unclosedGroupCount:ye(L)}),s.push(S),m=Y(m,T,h,L),M.lastIndex-=h.length-o.length}else if(q)i.size?(r&&(p++,c++),h!=="("&&(m=Y(m,T,h,o),M.lastIndex-=h.length-o.length)):r&&(a.push(X(a)+1+c-g),g=c,u++);else if((F||K)&&i.size){let w=F?+F:t.get(K)?.groupNum,L=!1;for(let I of s){let _=t.get(I);if(w>=_.groupNum&&w<=_.groupNum+_.numCaptures){L=!0;break}}if(L){let I=t.get(X(s)),_=u+c-p,P=`\\k<$$b${w}s${_}r${I.groupNum}c${I.numCaptures}>`;m=Y(m,T,h,P),M.lastIndex+=P.length-h.length}}else if(h===")"&&i.size){let w=i.get(X(s));w.unclosedGroupCount--,w.unclosedGroupCount||i.delete(s.pop())}}return r&&(m=N(m,String.raw`\\(?:(?<bNum>[1-9]\d*)|k<\$\$b(?<bNumSub>\d+)s(?<subNum>\d+)r(?<refNum>\d+)c(?<refCaps>\d+)>)`,({0:h,groups:{bNum:T,bNumSub:S,subNum:q,refNum:F,refCaps:K}})=>{if(T){let P=+T;if(P>a.length-1)throw new Error(`Backref "${h}" greater than number of captures`);return`\\${a[P]}`}let w=+S,L=+q,I=+F,_=+K;return w<I||w>I+_?`\\${a[w]}`:`\\${L-I+w}`},E.DEFAULT)),m}var J=new RegExp(String.raw`${Q}|\(\?:\)|(?<invalid>\\?.)`,"gsu");function Ke(e,t){let n=y(e,String.raw`\(\?\(DEFINE\)`,0,E.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:i,invalid:s}=o.groups;if(i){let a=he(r.contents,o),u;if(!t.get(i).isUnique)u=i;else{let c=Ae(a.contents);for(let p of c.keys())if(!t.get(p).isUnique){u=p;break}}if(u)throw new Error(`Duplicate group name "${u}" within DEFINE`);J.lastIndex=a.afterPos}else if(s)throw new Error("DEFINE group includes unsupported syntax at top level")}return e.slice(0,n.index)}function ye(e){let t=0;return k(e,"\\(",()=>t++,E.DEFAULT),t}function ve(e,t){let n=0,r=0,o;for(;o=y(e,O,r,E.DEFAULT);){let{0:i,index:s,groups:{captureName:a}}=o;if(n++,a===t)break;r=s+i.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 k(e,Q,({0:r,index:o,groups:{captureName:i}})=>{if(n.has(i))n.get(i).isUnique=!1;else{let s={isUnique:!0};if(t){let a=W(e,o+r.length);Object.assign(s,{contents:a,groupNum:ve(e,i),numCaptures:U(a)})}n.set(i,s)}},E.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 Ve="&!#%,:;<=>@`~",Qe=new RegExp(String.raw`
\[\^?-?
| --?\]
| (?<dp>[${R}])\k<dp>
| (?<dp>[${b}])\k<dp>
| --
| \\(?<vOnlyEscape>[${Ke}])
| \\(?<vOnlyEscape>[${Ve}])
| \\[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(ye)){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 ve=(e,...t)=>{if(Array.isArray(e?.raw))return te({},e,...t);if((typeof e=="string"||e===void 0)&&!t.length)return te.bind(null,{flags:e});if({}.toString.call(e)==="[object Object]"&&!t.length)return te.bind(null,e);throw new Error(`Unexpected arguments: ${JSON.stringify([e,...t])}`)},te=(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 c=l.v||(i.v?!1:se),p=(c?"v":"u")+r;i.x||({template:t,substitutions:n}=Z(t,n,fe)),i.n||({template:t,substitutions:n}=Z(t,n,le));let a=0,m="",E;if(t.raw.forEach((h,N)=>{let w=!!(t.raw[N]||t.raw[N+1]);a+=F(h),m+=M(h,g.CHAR_CLASS),E=U(m,E);let{regexContext:$,charClassContext:k}=E;if(N<t.raw.length-1){let T=n[N];m+=Ve(T,r,$,k,w,a),T instanceof RegExp?a+=F(T.source):T instanceof I&&(a+=F(String(T)))}}),[...u,...i.subroutines?[]:[Ne],...i.atomic?[]:[me,de],...i.x?[]:[pe],...c||!s?[]:[s]].forEach(h=>m=h(m,{flags:p,useEmulationGroups:o})),o){let h=je(m);return new ne(h.expression,p,{captureMap:h.captureMap})}return new RegExp(m,p)},ne=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!==f.DEFAULT)throw new Error("Cannot interpolate a RegExp at this position because the syntax context does not match");if(n===f.INVALID_INCOMPLETE_TOKEN||r===d.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===f.CHAR_CLASS?g.CHAR_CLASS:g.DEFAULT));let l=ue(i||e,n,r);if(l)throw new Error(`Unescaped stray "${l}" in the interpolated value would have side effects outside it`)}if(n===f.ENCLOSED_TOKEN||n===f.INTERVAL_QUANTIFIER||n===f.GROUP_NAME||r===d.ENCLOSED_TOKEN||r===d.Q_TOKEN)return s?String(e):i;if(n===f.CHAR_CLASS){if(s){if(V(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=ie(q(e));return z(e)?`[${l}]`:M(l)}return z(i)?`[${i}]`:i}if(e instanceof RegExp){let l=Qe(e,t),c=ae(l.value,u);return l.usedModifier?c:`(?:${c})`}return s?`(?:${e})`:o?`(?:${i})`:i}function Qe(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(G)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")&&(G?n.s=e.dotAll:o=A(o,"\\.",e.dotAll?"[^]":`[^${r}]`,g.DEFAULT)),e.multiline!==t.includes("m")&&(G?n.m=e.multiline:(o=A(o,"\\^",e.multiline?`(?<=^|[${r}])`:"(?<![^])",g.DEFAULT),o=A(o,"\\$",e.multiline?`(?=$|[${r}])`:"(?![^])",g.DEFAULT))),G){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 je(e){let t=C.replace(/\$/g,"\\$"),n=[!0];return e=A(e,`(?:${D})(?<mark>${t})?`,({0:r,groups:{mark:o}})=>o?(n.push(!1),r.slice(0,-C.length)):(n.push(!0),r),g.DEFAULT),{captureMap:n,expression:e}}return Le(qe);})();
`.replace(/\s+/g,""),"gsu");function we(e){let t='Invalid unescaped "-" in character class',n=!1,r="";for(let{0:o,groups:{dp:i,vOnlyEscape:s}}of e.matchAll(Qe)){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(i)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 je=(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 r=Se(e),o=Te(t,n,r),i=0,s="",a;if(o.template.raw.forEach((u,c)=>{let p=!!(o.template.raw[c]||o.template.raw[c+1]);i+=U(u),s+=G(u,E.CHAR_CLASS),a=D(s,a);let{regexContext:g,charClassContext:l}=a;if(c<o.template.raw.length-1){let m=o.substitutions[c];s+=He(m,r.flags,g,l,p,i),m instanceof RegExp?i+=U(m.source):m instanceof $&&(i+=U(String(m)))}}),s=$e(s,r),r.subclass){let u=Be(s);return new te(u.expression,r.flags,{captureMap:u.captureMap})}return new RegExp(s,r.flags)};function qe(e="",t={}){let n=Se(t);if(n.subclass)throw new Error("Option subclass not supported");return{expression:$e(Te({raw:[e]},[],n).template.raw[0],n),flags:n.flags}}function Se(e){let t={flags:"",subclass:!1,plugins:[],unicodeSetsPlugin:we,disable:{},force:{},...e};if(/[nuvx]/.test(t.flags))throw new Error("Implicit flags v/u/x/n cannot be explicitly added");let n=t.force.v||(t.disable.v?!1:oe);return t.flags+=n?"v":"u",t}function Te(e,t,n){let r=[];n.disable.x||r.push(fe),n.disable.n||r.push(le);for(let o of r)({template:e,substitutions:t}=ue(e,t,o,n));return{template:e,substitutions:t}}function $e(e,t){let{flags:n,plugins:r,unicodeSetsPlugin:o,disable:i,subclass:s}=t;return[...r,...i.subroutines?[]:[Ne],...i.atomic?[]:[me,de],...i.x?[]:[pe],...!o||n.includes("v")?[]:[o]].forEach(a=>e=a(e,{flags:n,useEmulationGroups:s})),e}var 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 He(e,t,n,r,o,i){if(e instanceof RegExp&&n!==f.DEFAULT)throw new Error("Cannot interpolate a RegExp at this position because the syntax context does not match");if(n===f.INVALID_INCOMPLETE_TOKEN||r===d.INVALID_INCOMPLETE_TOKEN)throw new Error("Interpolation preceded by invalid incomplete token");let s=e instanceof $,a="";if(!(e instanceof RegExp)){e=String(e),s||(a=B(e,n===f.CHAR_CLASS?E.CHAR_CLASS:E.DEFAULT));let u=ie(a||e,n,r);if(u)throw new Error(`Unescaped stray "${u}" in the interpolated value would have side effects outside it`)}if(n===f.ENCLOSED_TOKEN||n===f.INTERVAL_QUANTIFIER||n===f.GROUP_NAME||r===d.ENCLOSED_TOKEN||r===d.Q_TOKEN)return s?String(e):a;if(n===f.CHAR_CLASS){if(s){if(v(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 u=se(j(e));return z(e)?`[${u}]`:G(u)}return z(a)?`[${a}]`:a}if(e instanceof RegExp){let u=We(e,t),c=ae(u.value,i);return u.usedModifier?c:`(?:${c})`}return s?`(?:${e})`:o?`(?:${a})`:a}function We(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(x)n.i=e.ignoreCase;else throw new Error("Pattern modifiers not supported, so flag i on the outer and interpolated regex must match");if(e.dotAll!==t.includes("s")&&(x?n.s=e.dotAll:o=N(o,"\\.",e.dotAll?"[^]":`[^${r}]`,E.DEFAULT)),e.multiline!==t.includes("m")&&(x?n.m=e.multiline:(o=N(o,"\\^",e.multiline?`(?<=^|[${r}])`:"(?<![^])",E.DEFAULT),o=N(o,"\\$",e.multiline?`(?=$|[${r}])`:"(?![^])",E.DEFAULT))),x){let i=Object.keys(n),s=i.filter(u=>n[u]===!0).join(""),a=i.filter(u=>n[u]===!1).join("");if(a&&(s+=`-${a}`),s)return{value:`(?${s}:${o})`,usedModifier:!0}}return{value:o}}function Be(e){let t=C.replace(/\$/g,"\\$"),n=[!0];return e=N(e,`(?:${O})(?<mark>${t})?`,({0:r,groups:{mark:o}})=>o?(n.push(!1),r.slice(0,-C.length)):(n.push(!0),r),E.DEFAULT),{captureMap:n,expression:e}}return Oe(ze);})();
//# sourceMappingURL=regex.min.js.map
{
"name": "regex",
"version": "4.1.3",
"version": "4.2.0",
"description": "Regex template tag with extended syntax, context-aware interpolation, and always-on best practices",

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

"jasmine": "^5.2.0",
"regex-utilities": "^2.2.0",
"regex-utilities": "^2.3.0",
"typescript": "^5.5.4"
}
}
<div align="center">
<a href="https://github.com/slevithan/regex#readme">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://github.com/slevithan/regex/raw/main/media/regex-logo-dark.svg">
<img alt="regex logo" height="180" src="https://github.com/slevithan/regex/raw/main/media/regex-logo.svg">
<source media="(prefers-color-scheme: dark)" srcset="https://cdn.jsdelivr.net/gh/slevithan/regex@4.1.0/media/regex-logo-dark.svg">
<img alt="regex logo" height="180" src="https://cdn.jsdelivr.net/gh/slevithan/regex@4.1.0/media/regex-logo.svg">
</picture>

@@ -15,3 +15,3 @@ </a>

`regex` is a template tag that extends JavaScript regular expressions with features from other leading regex libraries that make regexes more powerful and dramatically more readable. It returns native `RegExp` instances that run with native performance, and can exceed the performance of regex literals you'd write yourself. It's also lightweight, has no dependencies, supports all ES2025 regex features, has built-in TypeScript declarations, and can be used as a [Babel plugin](https://github.com/slevithan/babel-plugin-transform-regex) to avoid any runtime dependencies or user runtime cost.
`regex` is a template tag that extends JavaScript regular expressions with key features from other leading regex libraries that make regexes more powerful and dramatically more readable. It returns native `RegExp` instances that run with native performance, and can exceed the performance of regex literals you'd write yourself. It's also lightweight, has no dependencies, supports all ES2025 regex features, has built-in TypeScript declarations, and can be used as a [Babel plugin](https://github.com/slevithan/babel-plugin-transform-regex) to avoid any runtime dependencies or user runtime cost.

@@ -122,3 +122,3 @@ 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.

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

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

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

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

2. Named capture mode changes the meaning of `\k` when a named capture appears anywhere in a regex.
3. Unicode mode with flag <kbd>u</kbd> adds strict errors (for unreserved letter escapes, octal escapes, escaped literal digits, quantified lookahead, and unescaped special characters in some contexts), switches to code-point-based matching (changing the potential handling of the dot, negated sets like `\W`, character class ranges, and quantifiers), changes flag <kbd>i</kbd> to apply Unicode case-folding, and adds support for new syntax.
3. Unicode mode with flag <kbd>u</kbd> adds strict errors (for unreserved escapes, octal escapes, quantified lookahead, etc.), switches to code point matching (changing the potential handling of the dot, negated sets like `\W`, character class ranges, and quantifiers), changes flag <kbd>i</kbd> to apply Unicode case-folding, and adds support for new syntax.
4. UnicodeSets mode with flag <kbd>v</kbd> (an upgrade to <kbd>u</kbd>) incompatibly changes escaping rules within character classes, fixes case-insensitive matching for `\p` and `\P` within negated `[^…]`, and adds support for new features/syntax.

@@ -222,3 +222,3 @@ </details>

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.
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 there's nothing left for the following `.` to match.

@@ -376,3 +376,3 @@ Here's how possessive quantifier syntax compares to the greedy and lazy quantifiers that JavaScript supports natively:

The `regex` plugin [regex-recursion](https://github.com/slevithan/regex-recursion) enables the syntax `(?R)` and `\g<name>` to match recursive patterns up to a specified max depth. This allows matching balanced constructs.
The `regex` plugin [regex-recursion](https://github.com/slevithan/regex-recursion) enables the syntax `(?R)` and `\g<name>` to match recursive/balanced patterns up to a specified max depth.

@@ -412,5 +412,5 @@ ## 🚩 Flags

# Match a date in YYYY-MM-DD format
(?<year> \d{4} ) - # Year part
(?<month> \d{2} ) - # Month part
(?<day> \d{2} ) # Day part
(?<year> \d{4}) - # Year part
(?<month> \d{2}) - # Month part
(?<day> \d{2}) # Day part

@@ -464,3 +464,3 @@ # Escape whitespace and hashes to match them literally

> [!NOTE]
> Flag <kbd>n</kbd> is based on .NET, C++, PCRE, Perl, and XRegExp, which share the <kbd>n</kbd> flag letter but call it *explicit capture*, *no auto capture*, or *nosubs*. In `regex`, the implicit flag <kbd>n</kbd> also prevents using numbered backreferences to refer to named groups in the outer regex, which follows the behavior of C++ (Ruby also always prevents this, despite not having flag <kbd>n</kbd>). Referring to named groups by number is a footgun, and the way that named groups are numbered is inconsistent across regex flavors.
> Flag <kbd>n</kbd> is based on .NET, C++, PCRE, Perl, and XRegExp, which share the <kbd>n</kbd> flag letter but call it *explicit capture*, *no auto capture*, or *nosubs*. In `regex`, flag <kbd>n</kbd> also prevents using numbered backreferences to refer to named groups in the outer regex, which follows the behavior of C++ (Ruby also always prevents this, despite not having flag <kbd>n</kbd>). Referring to named groups by number is a footgun, and the way that named groups are numbered is inconsistent across regex flavors.

@@ -525,3 +525,3 @@ ## 🧩 Interpolation

- A `~` is not escaped at the top level, but it must be escaped within character classes in case it's immediately followed by another `~` (in or outside of the interpolation) which would turn it into a reserved UnicodeSets double punctuator.
- A `~` is not escaped at the top level, but it must be escaped within character classes if it's immediately preceded or followed by another `~` (in or outside of the interpolation) which would turn it into a reserved UnicodeSets double punctuator.
- Leading digits must be escaped if they're preceded by a numbered backreference or `\0`, else `RegExp` throws (or in Unicode-unaware mode they might turn into octal escapes).

@@ -631,4 +631,6 @@ - Letters `A`-`Z` and `a`-`z` must be escaped if preceded by uncompleted token `\c`, else they'll convert what should be an error into a valid token that probably doesn't match what you expect.

> Implementation note: `pattern` returns an object with a custom `toString` that simply returns `String(value)`. However, patterns are not intended as an intermediate regex type. You can think of `pattern` as a directive to the `regex` tag: treat this string as a partial pattern rather than a string to be matched literally.
> Implementation note: `pattern` returns an object with a custom `toString` that simply returns `String(value)`.
> Patterns are not intended as an intermediate regex type. You can think of `pattern` as a directive to the `regex` tag: treat this string as a partial pattern rather than a string to be matched literally.
### Interpolation principles

@@ -745,6 +747,6 @@

> `regex` is not primarily a backward compatibility library, so in order to remain lightweight, it doesn't transpile flag <kbd>v</kbd>'s new features out of the box. By replacing the default function, you can add backward compatible support for these features. See also: [*Compatibility*](#-compatibility).
- Setting `unicodeSetsPlugin` to `null` prevents `regex` from applying flag <kbd>v</kbd>'s escaping rules. This can be useful in combination with option `disable: {v: true}` for tools that want to use `regex`'s extended syntax and/or flags but need to accept input with flag <kbd>u</kbd>'s escaping rules.
- `regex` is not primarily a backward compatibility library, so in order to remain lightweight, it doesn't transpile flag <kbd>v</kbd>'s new features out of the box. By replacing the default function, you can add backward compatible support for these features. See also: [*Compatibility*](#-compatibility).
- This plugin runs last, which means it's possible to wrap an existing library (e.g. [regexpu-core](https://github.com/mathiasbynens/regexpu-core), used by Babel to [transpile <kbd>v</kbd>](https://babel.dev/docs/babel-plugin-transform-unicode-sets-regex)), without the library needing to understand `regex`'s extended syntax.
> This plugin runs last, which means it's possible to wrap an existing library (e.g. [regexpu-core](https://github.com/mathiasbynens/regexpu-core), used by Babel to [transpile <kbd>v</kbd>](https://babel.dev/docs/babel-plugin-transform-unicode-sets-regex)), without the library needing to understand `regex`'s extended syntax.
**`disable`** β€” A set of options that can be individually disabled by setting their values to `true`.

@@ -763,2 +765,12 @@

For tools that want processed output as a string rather than a regex, you can use function `processRegex`:
```js
import {processRegex} from 'regex';
processRegex('^ . $', {flags: 'g'});
// β†’ {expression: '^.$', flags: 'gv'}
```
`processRegex` shares `regex`'s options (described above). Passing the resulting `expression` and `flags` properties to the `RegExp` constructor gives the same result as a tagged `regex` template. However, since `processRegex` isn't a template tag, it doesn't provide context-aware interpolation, and it doesn't automatically handle input as a raw string (so you need to escape your backslashes).
## ⚑ Performance

@@ -824,5 +836,6 @@

`regex` was partly inspired by [XRegExp](https://github.com/slevithan/xregexp)'s `.tag` and [regexp-make-js](https://github.com/mikesamuel/regexp-make-js).
`regex` was crafted by [Steven Levithan](https://github.com/slevithan) and [contributors](https://github.com/slevithan/regex/graphs/contributors), with love for regular expressions and their enthusiasts. Inspiration included [PCRE](https://github.com/PCRE2Project/pcre2), [XRegExp](https://github.com/slevithan/xregexp), and [regexp-make-js](https://github.com/mikesamuel/regexp-make-js).
Crafted by Steven Levithan with love for regular expressions and their enthusiasts.<br>
If you want to support this project, I'd love your help by contributing improvements, sharing it with others, or [sponsoring](https://github.com/sponsors/slevithan) future development.
MIT License.

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

export function flagNPreprocessor(value: import("./utils.js").InterpolatedValue, runningContext: import("./utils.js").RunningContext): {
export function flagNPreprocessor(value: import("./utils.js").InterpolatedValue, runningContext: import("./utils.js").RunningContext, options: Required<import("./utils.js").RegexTagOptions>): {
transformed: string;

@@ -3,0 +3,0 @@ runningContext: import("./utils.js").RunningContext;

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

export function flagXPreprocessor(value: import("./utils.js").InterpolatedValue, runningContext: import("./utils.js").RunningContext): {
export function flagXPreprocessor(value: import("./utils.js").InterpolatedValue, runningContext: import("./utils.js").RunningContext, options: Required<import("./utils.js").RegexTagOptions>): {
transformed: string;

@@ -3,0 +3,0 @@ runningContext: import("./utils.js").RunningContext;

@@ -81,2 +81,12 @@ export type InterpolatedValue = string | RegExp | Pattern | number;

import { pattern } from './pattern.js';
/**
Returns the processed expression and flags as strings.
@param {string} expression
@param {RegexTagOptions} [options]
@returns {{expression: string; flags: string;}}
*/
export function processRegex(expression?: string, options?: RegexTagOptions): {
expression: string;
flags: string;
};
import { Pattern } from './pattern.js';

@@ -83,0 +93,0 @@ declare class WrappedRegExp extends RegExp {

@@ -49,3 +49,8 @@ /**

@typedef {import('./regex.js').RawTemplate} RawTemplate
@typedef {(value: InterpolatedValue, runningContext: RunningContext) => {
@typedef {import('./regex.js').RegexTagOptions} RegexTagOptions
@typedef {(
value: InterpolatedValue,
runningContext: RunningContext,
options: Required<RegexTagOptions>
) => {
transformed: string;

@@ -61,5 +66,6 @@ runningContext: RunningContext;

@param {Preprocessor} preprocessor
@param {Required<RegexTagOptions>} options
@returns {{template: RawTemplate; substitutions: ReadonlyArray<InterpolatedValue>;}}
*/
export function preprocess(template: RawTemplate, substitutions: ReadonlyArray<InterpolatedValue>, preprocessor: Preprocessor): {
export function preprocess(template: RawTemplate, substitutions: ReadonlyArray<InterpolatedValue>, preprocessor: Preprocessor, options: Required<RegexTagOptions>): {
template: RawTemplate;

@@ -101,5 +107,6 @@ substitutions: ReadonlyArray<InterpolatedValue>;

export type RawTemplate = import("./regex.js").RawTemplate;
export type Preprocessor = (value: InterpolatedValue, runningContext: RunningContext) => {
export type RegexTagOptions = import("./regex.js").RegexTagOptions;
export type Preprocessor = (value: InterpolatedValue, runningContext: RunningContext, options: Required<RegexTagOptions>) => {
transformed: string;
runningContext: RunningContext;
};

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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