1import"../chunks/Bzak7iHL.js";import"../chunks/kfVmCPsV.js";import{p as l,g as p,d as c,b as h,s as k,f as d,a as y,e as m,r as v,n as u}from"../chunks/C2PHntuy.js";import{h as g}from"../chunks/C3QlhiH-.js";import{i as f}from"../chunks/BQOOHHT8.js";import{l as x,s as q}from"../chunks/gzNpScmH.js";import{B as w}from"../chunks/B1caYEk9.js";import{t as _}from"../chunks/C3bQ3Oc7.js";const a={title:"Lazy quantifier in regex",tags:["regex"],description:"Lazy quantifier in regex `?`Add `?` at the behind `*` or `+` to make them less greedy.https://twitter.com/lihautan/status/1177476277277560832https://javascript.info/regexp-greedy-and-lazy..."},{title:D,tags:E,description:F}=a;var $=h('<p>Lazy quantifier in regex <code class="inline">?</code></p> <p>Add <code class="inline">?</code> at the behind <code class="inline">*</code> or <code class="inline">+</code> to make them less greedy.</p> <div class="code-section"><!></div> <ul><li><a href="https://twitter.com/lihautan/status/1177476277277560832" rel="nofollow">https://twitter.com/lihautan/status/1177476277277560832</a></li> <li><a href="https://javascript.info/regexp-greedy-and-lazy" rel="nofollow">https://javascript.info/regexp-greedy-and-lazy</a></li></ul>',1);function G(e,s){const n=x(s,["children","$$slots","$$events","$$legacy"]);l(s,!1),p("blog",{image:_}),f(),w(e,q(()=>n,()=>a,{children:(r,b)=>{var o=$(),t=k(d(o),4),i=m(t);g(i,()=>`<pre class="shiki" style="background-color: var(--shiki-color-background)"><code><span class="line"><span style="color: var(--shiki-token-keyword)">const</span><span style="color: var(--shiki-color-text)"> </span><span style="color: var(--shiki-token-constant)">sentence</span><span style="color: var(--shiki-color-text)"> </span><span style="color: var(--shiki-token-keyword)">=</span><span style="color: var(--shiki-color-text)"> </span><span style="color: var(--shiki-token-string-expression)">`a "witch" and her "broom" is one`</span><span style="color: var(--shiki-color-text)">;</span></span> 2<span class="line"></span> 3<span class="line"><span style="color: var(--shiki-token-constant)">sentence</span><span style="color: var(--shiki-token-function)">.match</span><span style="color: var(--shiki-color-text)">(</span><span style="color: var(--shiki-token-string-expression)">/".</span><span style="color: var(--shiki-token-keyword)">+</span><span style="color: var(--shiki-token-string-expression)">"/</span><span style="color: var(--shiki-color-text)">); </span><span style="color: var(--shiki-token-comment)">// `"witch" and her "broom"`</span></span> 4<span class="line"><span style="color: var(--shiki-token-comment)">// lazy</span></span> 5<span class="line"><span style="color: var(--shiki-token-constant)">sentence</span><span style="color: var(--shiki-token-function)">.match</span><span style="color: var(--shiki-color-text)">(</span><span style="color: var(--shiki-token-string-expression)">/".</span><span style="color: var(--shiki-token-keyword)">+?</span><span style="color: var(--shiki-token-string-expression)">"/</span><span style="color: var(--shiki-color-text)">); </span><span style="color: var(--shiki-token-comment)">// `"witch"`</span></span></code></pre>`),v(t),u(2),y(r,o)},$$slots:{default:!0}})),c()}export{G as component};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.