[{"data":1,"prerenderedAt":919},["ShallowReactive",2],{"blog-regex-cheat-sheet-for-developers":3},{"id":4,"title":5,"body":6,"category":906,"date":907,"description":908,"extension":909,"meta":910,"navigation":911,"path":912,"readingTime":913,"seo":914,"stem":915,"tool":916,"updated":917,"__hash__":918},"blog\u002Fblog\u002Fregex-cheat-sheet-for-developers.md","RegEx Cheat Sheet for Developers",{"type":7,"value":8,"toc":883},"minimark",[9,13,18,169,173,266,276,286,290,346,350,427,431,494,498,565,568,574,578,671,675,680,694,698,707,711,720,724,733,737,746,750,759,763,772,776,785,789,867,871,879],[10,11,12],"p",{},"Regular expressions (regex) are one of the most powerful text processing tools available to developers — and one of the most frequently forgotten. This cheat sheet covers the syntax you need for everyday pattern matching, from basic metacharacters to advanced lookahead assertions.",[14,15,17],"h2",{"id":16},"basic-metacharacters","Basic Metacharacters",[19,20,21,37],"table",{},[22,23,24],"thead",{},[25,26,27,31,34],"tr",{},[28,29,30],"th",{},"Pattern",[28,32,33],{},"Matches",[28,35,36],{},"Example",[38,39,40,58,74,90,106,121,137,153],"tbody",{},[25,41,42,49,52],{},[43,44,45],"td",{},[46,47,48],"code",{},".",[43,50,51],{},"Any character except newline",[43,53,54,57],{},[46,55,56],{},"a.c"," → \"abc\", \"a1c\"",[25,59,60,65,68],{},[43,61,62],{},[46,63,64],{},"\\d",[43,66,67],{},"Any digit (0-9)",[43,69,70,73],{},[46,71,72],{},"\\d{3}"," → \"123\"",[25,75,76,81,84],{},[43,77,78],{},[46,79,80],{},"\\D",[43,82,83],{},"Any non-digit",[43,85,86,89],{},[46,87,88],{},"\\D+"," → \"abc\"",[25,91,92,97,100],{},[43,93,94],{},[46,95,96],{},"\\w",[43,98,99],{},"Word character (a-z, A-Z, 0-9, _)",[43,101,102,105],{},[46,103,104],{},"\\w+"," → \"hello_world\"",[25,107,108,113,116],{},[43,109,110],{},[46,111,112],{},"\\W",[43,114,115],{},"Non-word character",[43,117,118,120],{},[46,119,112],{}," → \"@\", \" \"",[25,122,123,128,131],{},[43,124,125],{},[46,126,127],{},"\\s",[43,129,130],{},"Whitespace (space, tab, newline)",[43,132,133,136],{},[46,134,135],{},"\\s+"," → \"  \"",[25,138,139,144,147],{},[43,140,141],{},[46,142,143],{},"\\S",[43,145,146],{},"Non-whitespace",[43,148,149,152],{},[46,150,151],{},"\\S+"," → \"hello\"",[25,154,155,160,163],{},[43,156,157],{},[46,158,159],{},"\\b",[43,161,162],{},"Word boundary",[43,164,165,168],{},[46,166,167],{},"\\bcat\\b"," → \"cat\" but not \"catch\"",[14,170,172],{"id":171},"quantifiers","Quantifiers",[19,174,175,184],{},[22,176,177],{},[25,178,179,181],{},[28,180,30],{},[28,182,183],{},"Meaning",[38,185,186,196,206,216,226,236,246,256],{},[25,187,188,193],{},[43,189,190],{},[46,191,192],{},"*",[43,194,195],{},"0 or more",[25,197,198,203],{},[43,199,200],{},[46,201,202],{},"+",[43,204,205],{},"1 or more",[25,207,208,213],{},[43,209,210],{},[46,211,212],{},"?",[43,214,215],{},"0 or 1 (optional)",[25,217,218,223],{},[43,219,220],{},[46,221,222],{},"{n}",[43,224,225],{},"Exactly n",[25,227,228,233],{},[43,229,230],{},[46,231,232],{},"{n,}",[43,234,235],{},"n or more",[25,237,238,243],{},[43,239,240],{},[46,241,242],{},"{n,m}",[43,244,245],{},"Between n and m",[25,247,248,253],{},[43,249,250],{},[46,251,252],{},"*?",[43,254,255],{},"0 or more (lazy\u002Fnon-greedy)",[25,257,258,263],{},[43,259,260],{},[46,261,262],{},"+?",[43,264,265],{},"1 or more (lazy\u002Fnon-greedy)",[10,267,268,272,273,275],{},[269,270,271],"strong",{},"Greedy vs lazy:"," By default, quantifiers are greedy — they match as much as possible. Adding ",[46,274,212],{}," makes them lazy — matching as little as possible.",[277,278,283],"pre",{"className":279,"code":281,"language":282},[280],"language-text","\"\u003Cb>bold\u003C\u002Fb>\" with \u003C.*>  → matches \"\u003Cb>bold\u003C\u002Fb>\" (greedy)\n\"\u003Cb>bold\u003C\u002Fb>\" with \u003C.*?> → matches \"\u003Cb>\" (lazy)\n","text",[46,284,281],{"__ignoreMap":285},"",[14,287,289],{"id":288},"anchors","Anchors",[19,291,292,300],{},[22,293,294],{},[25,295,296,298],{},[28,297,30],{},[28,299,33],{},[38,301,302,316,328,336],{},[25,303,304,309],{},[43,305,306],{},[46,307,308],{},"^",[43,310,311,312,315],{},"Start of string (or line with ",[46,313,314],{},"m"," flag)",[25,317,318,323],{},[43,319,320],{},[46,321,322],{},"$",[43,324,325,326,315],{},"End of string (or line with ",[46,327,314],{},[25,329,330,334],{},[43,331,332],{},[46,333,159],{},[43,335,162],{},[25,337,338,343],{},[43,339,340],{},[46,341,342],{},"\\B",[43,344,345],{},"Non-word boundary",[14,347,349],{"id":348},"character-classes","Character Classes",[19,351,352,360],{},[22,353,354],{},[25,355,356,358],{},[28,357,30],{},[28,359,33],{},[38,361,362,372,382,392,402,415],{},[25,363,364,369],{},[43,365,366],{},[46,367,368],{},"[abc]",[43,370,371],{},"Any of a, b, or c",[25,373,374,379],{},[43,375,376],{},[46,377,378],{},"[^abc]",[43,380,381],{},"Any character except a, b, c",[25,383,384,389],{},[43,385,386],{},[46,387,388],{},"[a-z]",[43,390,391],{},"Any lowercase letter",[25,393,394,399],{},[43,395,396],{},[46,397,398],{},"[A-Z]",[43,400,401],{},"Any uppercase letter",[25,403,404,409],{},[43,405,406],{},[46,407,408],{},"[0-9]",[43,410,411,412,414],{},"Any digit (same as ",[46,413,64],{},")",[25,416,417,422],{},[43,418,419],{},[46,420,421],{},"[a-zA-Z0-9_]",[43,423,424,425],{},"Same as ",[46,426,96],{},[14,428,430],{"id":429},"groups-and-alternation","Groups and Alternation",[19,432,433,442],{},[22,434,435],{},[25,436,437,439],{},[28,438,30],{},[28,440,441],{},"Purpose",[38,443,444,454,464,474,484],{},[25,445,446,451],{},[43,447,448],{},[46,449,450],{},"(abc)",[43,452,453],{},"Capturing group",[25,455,456,461],{},[43,457,458],{},[46,459,460],{},"(?:abc)",[43,462,463],{},"Non-capturing group",[25,465,466,471],{},[43,467,468],{},[46,469,470],{},"(?\u003Cname>abc)",[43,472,473],{},"Named capturing group",[25,475,476,481],{},[43,477,478],{},[46,479,480],{},"a|b",[43,482,483],{},"Alternation (a or b)",[25,485,486,491],{},[43,487,488],{},[46,489,490],{},"\\1",[43,492,493],{},"Backreference to group 1",[14,495,497],{"id":496},"lookahead-and-lookbehind","Lookahead and Lookbehind",[19,499,500,511],{},[22,501,502],{},[25,503,504,506,509],{},[28,505,30],{},[28,507,508],{},"Name",[28,510,33],{},[38,512,513,526,539,552],{},[25,514,515,520,523],{},[43,516,517],{},[46,518,519],{},"(?=abc)",[43,521,522],{},"Positive lookahead",[43,524,525],{},"Followed by \"abc\"",[25,527,528,533,536],{},[43,529,530],{},[46,531,532],{},"(?!abc)",[43,534,535],{},"Negative lookahead",[43,537,538],{},"NOT followed by \"abc\"",[25,540,541,546,549],{},[43,542,543],{},[46,544,545],{},"(?\u003C=abc)",[43,547,548],{},"Positive lookbehind",[43,550,551],{},"Preceded by \"abc\"",[25,553,554,559,562],{},[43,555,556],{},[46,557,558],{},"(?\u003C!abc)",[43,560,561],{},"Negative lookbehind",[43,563,564],{},"NOT preceded by \"abc\"",[10,566,567],{},"Lookarounds are zero-width assertions — they check a condition without consuming characters.",[277,569,572],{"className":570,"code":571,"language":282},[280],"\\d+(?= dollars)     → \"100\" in \"100 dollars\"\n(?\u003C=\\$)\\d+           → \"50\" in \"$50\"\n\\b\\w+(?!ing\\b)       → words not ending in \"ing\"\n",[46,573,571],{"__ignoreMap":285},[14,575,577],{"id":576},"flags","Flags",[19,579,580,592],{},[22,581,582],{},[25,583,584,587,589],{},[28,585,586],{},"Flag",[28,588,508],{},[28,590,591],{},"Effect",[38,593,594,607,626,643,658],{},[25,595,596,601,604],{},[43,597,598],{},[46,599,600],{},"g",[43,602,603],{},"Global",[43,605,606],{},"Find all matches, not just the first",[25,608,609,614,617],{},[43,610,611],{},[46,612,613],{},"i",[43,615,616],{},"Case-insensitive",[43,618,619,622,623],{},[46,620,621],{},"a"," matches ",[46,624,625],{},"A",[25,627,628,632,635],{},[43,629,630],{},[46,631,314],{},[43,633,634],{},"Multiline",[43,636,637,639,640,642],{},[46,638,308],{}," and ",[46,641,322],{}," match line boundaries",[25,644,645,650,653],{},[43,646,647],{},[46,648,649],{},"s",[43,651,652],{},"Dotall",[43,654,655,657],{},[46,656,48],{}," matches newline characters",[25,659,660,665,668],{},[43,661,662],{},[46,663,664],{},"u",[43,666,667],{},"Unicode",[43,669,670],{},"Full Unicode support",[14,672,674],{"id":673},"practical-patterns","Practical Patterns",[676,677,679],"h3",{"id":678},"email-simplified","Email (simplified)",[277,681,685],{"className":682,"code":683,"language":684,"meta":285,"style":285},"language-regex shiki shiki-themes github-light github-dark","[\\w.-]+@[\\w.-]+\\.\\w{2,}\n","regex",[46,686,687],{"__ignoreMap":285},[688,689,692],"span",{"class":690,"line":691},"line",1,[688,693,683],{},[676,695,697],{"id":696},"url","URL",[277,699,701],{"className":682,"code":700,"language":684,"meta":285,"style":285},"https?:\\\u002F\\\u002F[\\w.-]+(?:\\\u002F[\\w.\u002F?#&=-]*)?\n",[46,702,703],{"__ignoreMap":285},[688,704,705],{"class":690,"line":691},[688,706,700],{},[676,708,710],{"id":709},"ipv4-address","IPv4 Address",[277,712,714],{"className":682,"code":713,"language":684,"meta":285,"style":285},"\\b(?:\\d{1,3}\\.){3}\\d{1,3}\\b\n",[46,715,716],{"__ignoreMap":285},[688,717,718],{"class":690,"line":691},[688,719,713],{},[676,721,723],{"id":722},"date-yyyy-mm-dd","Date (YYYY-MM-DD)",[277,725,727],{"className":682,"code":726,"language":684,"meta":285,"style":285},"\\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\\d|3[01])\n",[46,728,729],{"__ignoreMap":285},[688,730,731],{"class":690,"line":691},[688,732,726],{},[676,734,736],{"id":735},"phone-number-us","Phone Number (US)",[277,738,740],{"className":682,"code":739,"language":684,"meta":285,"style":285},"(?:\\+1[-.\\s]?)?(?:\\(?\\d{3}\\)?[-.\\s]?)?\\d{3}[-.\\s]?\\d{4}\n",[46,741,742],{"__ignoreMap":285},[688,743,744],{"class":690,"line":691},[688,745,739],{},[676,747,749],{"id":748},"hex-color","Hex Color",[277,751,753],{"className":682,"code":752,"language":684,"meta":285,"style":285},"#(?:[0-9a-fA-F]{3}){1,2}\\b\n",[46,754,755],{"__ignoreMap":285},[688,756,757],{"class":690,"line":691},[688,758,752],{},[676,760,762],{"id":761},"html-tag","HTML Tag",[277,764,766],{"className":682,"code":765,"language":684,"meta":285,"style":285},"\u003C\\\u002F?[\\w]+(?:\\s+[\\w-]+(?:=\"[^\"]*\")?)*\\s*\\\u002F?>\n",[46,767,768],{"__ignoreMap":285},[688,769,770],{"class":690,"line":691},[688,771,765],{},[676,773,775],{"id":774},"password-strength-8-chars-upper-lower-digit","Password Strength (8+ chars, upper, lower, digit)",[277,777,779],{"className":682,"code":778,"language":684,"meta":285,"style":285},"^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d).{8,}$\n",[46,780,781],{"__ignoreMap":285},[688,782,783],{"class":690,"line":691},[688,784,778],{},[14,786,788],{"id":787},"common-mistakes","Common Mistakes",[790,791,792,833,846,857],"ol",{},[793,794,795,798,799,801,802,801,804,801,806,801,808,801,811,801,813,801,816,801,819,801,822,801,824,801,826,829,830,832],"li",{},[269,796,797],{},"Not escaping special characters"," — ",[46,800,48],{},", ",[46,803,192],{},[46,805,202],{},[46,807,212],{},[46,809,810],{},"(",[46,812,414],{},[46,814,815],{},"[",[46,817,818],{},"{",[46,820,821],{},"\\",[46,823,308],{},[46,825,322],{},[46,827,828],{},"|"," all have special meaning. Escape them with ",[46,831,821],{}," when matching literally.",[793,834,835,798,838,841,842,845],{},[269,836,837],{},"Greedy matching",[46,839,840],{},".*"," in the middle of a pattern often matches more than expected. Use ",[46,843,844],{},".*?"," for lazy matching or be more specific.",[793,847,848,851,852,639,854,856],{},[269,849,850],{},"Not anchoring"," — without ",[46,853,308],{},[46,855,322],{},", a pattern can match anywhere in the string, not just the full string.",[793,858,859,862,863,866],{},[269,860,861],{},"Catastrophic backtracking"," — nested quantifiers like ",[46,864,865],{},"(a+)+b"," can cause exponential backtracking. Avoid patterns where the regex engine has too many ways to match.",[14,868,870],{"id":869},"try-it","Try It",[10,872,873,874,878],{},"Test your regex patterns with live highlighting using ",[621,875,877],{"href":876},"\u002Ftools\u002Fregex-tester","StackCache Regex Tester",". See matches, capture groups, and named groups in real time — all locally in your browser.",[880,881,882],"style",{},"html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":285,"searchDepth":884,"depth":884,"links":885},2,[886,887,888,889,890,891,892,893,904,905],{"id":16,"depth":884,"text":17},{"id":171,"depth":884,"text":172},{"id":288,"depth":884,"text":289},{"id":348,"depth":884,"text":349},{"id":429,"depth":884,"text":430},{"id":496,"depth":884,"text":497},{"id":576,"depth":884,"text":577},{"id":673,"depth":884,"text":674,"children":894},[895,897,898,899,900,901,902,903],{"id":678,"depth":896,"text":679},3,{"id":696,"depth":896,"text":697},{"id":709,"depth":896,"text":710},{"id":722,"depth":896,"text":723},{"id":735,"depth":896,"text":736},{"id":748,"depth":896,"text":749},{"id":761,"depth":896,"text":762},{"id":774,"depth":896,"text":775},{"id":787,"depth":884,"text":788},{"id":869,"depth":884,"text":870},"Reference","2026-09-08","A practical regex reference with patterns for emails, URLs, IPs, dates, and more. Covers metacharacters, quantifiers, groups, lookahead, and flags.","md",{},true,"\u002Fblog\u002Fregex-cheat-sheet-for-developers",8,{"title":5,"description":908},"blog\u002Fregex-cheat-sheet-for-developers","regex-tester",null,"Tr56_w7fl9qLYaMEYGyZebCxaGingnJUgdfCLftlLuY",1788868139394]