regex-riddles/template.html

34 lines
34 KiB
HTML
Raw Normal View History

2024-05-17 20:41:05 +02:00
<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8"> <title>RegExr: Learn, Build, &amp; Test RegEx</title> <script async src="https://www.googletagmanager.com/gtag/js?id=G-FS551ZDYMX"></script> <script> window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-FS551ZDYMX'); </script> <script id="regexWorker" type="javascript/worker"> onmessage=function(e){postMessage("onload");var t,s,n,a=e.data,i=a.text,d=a.tests,l=a.mode,r=new RegExp(a.pattern,a.flags),o=[];if("tests"===l)for(var g=0,x=d.length;g<x;g++){let e=d[g];i=e.text,r.lastIndex=0,t=r.exec(i),o[g]=t?{i:t.index,l:t[0].length,id:e.id}:{id:e.id}}else for(;t=r.exec(i);){s===r.lastIndex&&(n={id:"infinite",warning:!0},++r.lastIndex),s=r.lastIndex;var f=t.reduce(function(e,t,s){return(0===s||e.push({s:t}))&&e},[]);if(o.push({i:t.index,l:t[0].length,groups:f}),!r.global)break}postMessage({error:n,matches:o,mode:l})}; </script> <link href="https://fonts.googleapis.com/css2?family=Roboto+Condensed:wght@400;700&family=Source+Code+Pro:wght@200;400;700&display=swap" rel="stylesheet"> <link rel="stylesheet" type="text/css" href="regexr.css"> <meta name="title" content="RegExr: Learn, Build, & Test RegEx"> <meta name="description" content="Regular expression tester with syntax highlighting, PHP / PCRE & JS Support, contextual help, cheat sheet, reference, and searchable community patterns."> <meta id="viewport" name="viewport" content="width=device-width,initial-scale=1,user-scalable=0"> <link rel="apple-touch-icon" sizes="180x180" href="/assets/icons/apple-touch-icon.png?1"> <link rel="icon" type="image/png" sizes="32x32" href="/assets/icons/favicon-32x32.png?1"> <link rel="icon" type="image/png" sizes="16x16" href="/assets/icons/favicon-16x16.png?1"> <link rel="manifest" href="/assets/icons/site.webmanifest?1"> <link rel="mask-icon" href="/assets/icons/safari-pinned-tab.svg?1" color="#70b0e0"> <link rel="shortcut icon" href="/assets/icons/favicon.ico?1"> <meta name="apple-mobile-web-app-title" content="RegExr"> <meta name="application-name" content="RegExr"> <meta name="msapplication-TileColor" content="#70b0e0"> <meta name="msapplication-config" content="/assets/icons/browserconfig.xml"> <meta name="theme-color" content="#70b0e0"> <meta property="og:image" content="https://regexr.com/assets/card.png"> <meta property="og:image:width" content="1200"> <meta property="og:image:height" content="630"> <meta property="og:title" content="RegExr: Learn, Build, & Test RegEx"> <meta property="og:description" content="RegExr is an online tool to learn, build, & test Regular Expressions (RegEx / RegExp)."> <meta property="og:url" content="https://regexr.com/"> <meta property="og:site_name" content="RegExr"> <meta name="twitter:card" content="summary_large_image"> <meta name="twitter:site:id" content="@gskinner"> <meta name="twitter:title" content="RegExr: Learn, Build, & Test RegEx"> <meta name="twitter:description" content="RegExr is an online tool to learn, build, & test Regular Expressions (RegEx / RegExp)."> <meta name="twitter:image" content="https://regexr.com/assets/card.png"> <meta name="twitter:url" content="https://regexr.com/"> </head> <body> <div style="display:none;"> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><symbol id="RegExr" viewBox="0 0 64 64"><path d="M0 0v64h64V0H0zm23.799 52.045H11.783V40.029h12.016v12.016zm29.957-22.401l-5.396 5.235-6.765-11.033L34.67 35.12l-5.396-5.235 9.744-7.328-13.046-4.188 3.785-6.604 10.711 8.617L37.65 7.739h7.57l-2.899 12.643 10.791-8.617 3.785 6.604-12.804 4.027 9.663 7.248z"/></symbol><symbol id="add" viewBox="0 0 332.07 332.08"><path d="M332.07 124.49H207.59V0h-83.11v124.49H0v83.1h124.48v124.49h83.11V207.59h124.48v-83.1z"/></symbol><symbol id="alert" viewBox="0 0 584.053 503.947"><path d="M306.207 358.43h-30.758L258.317 216.54v-77.127h64.611v77.127zm15.277 84.222h-61.72v-59.657h61.72zM292.027.002L0 503.946h584.048z"/></symbol><symbol id="arrowleft" viewBox="0 0 14.2 21"><path d="M10.5 21l3.7-3.7-6.8-6.8 6.8-6.8L10.5 0 0 10.5z"/></symbol><symbol id="arrowright" viewBox="0 0 14.2 21"><path d="M14.2 10.5L3.7 0 0 3.7l6.8 6.8L0 17.3 3.7 21z"/></symbol><symbol id="cheatsheet" viewBox="0 0 397.427 562.667"><path d="M199.147 98.423c11.338 0 20.53-9.196 20.53-20.534V20.528C219.677 9.191 210.485 0 199.147 0c-11.338 0-20.528 9.19-20.528 20.528v5
background: linear-gradient(-30deg, #native_bg_color#E5, #native_bg_color#E5 45%, #native_bg_color# 45%) #fff;
}
.native-details {
color: #native_color# !important;
}
.native-details:hover {
color: #native_color_hover# !important;
} </style> <div class="native-main"> <img class="native-img" src="#native_logo#"> <div class="native-details"> <span class="native-company">Sponsored by #native_company#</span> <span class="native-desc">#native_desc#</span> </div> </div> </a> </div> <div class="noad"> <b>Want to support RegExr?</b> Consider disabling your ad-blocker for this domain. We'll show a non-intrusive, dev-oriented ad in this area. </div> </div> </div> <div class="min"> <ul class="list"></ul> </div> </aside> <div class="doc"> <div class="blocker"></div> <section class="expression"> <header> <h1>Expression</h1> <div class="controlbar"> <div class="button flavor"> <svg class="icon"><use xlink:href="#code"></use></svg> <span class="label">JavaScript</span> <svg class="icon dropdown"><use xlink:href="#dropdown"></use></svg> </div> <div class="button flags"> <svg class="icon"><use xlink:href="#flags"></use></svg> <span class="label">Flags</span> <svg class="icon dropdown"><use xlink:href="#dropdown"></use></svg> </div> </div> </header> <article class="editor"><svg class="icon alert"><use xlink:href="#alert"></use></svg></article> </section> <section class="text"> <header> <h1> <ul class="segcontrol modelist"></ul> </h1> <div class="button add"> <svg class="icon add"><use xlink:href="#add"></use></svg> <span class="label">Add Test</span> </div> <div class="controlbar"> <div class="control result">No match.</div> </div> </header> <article> <article class="editor multiline"><div class="pad"> <textarea>
<replace with text>
</textarea> </div></article> <div class="tests"> <ul class="list"></ul> <div class="add button"> <svg class="icon add"><use xlink:href="#add"></use></svg> <span class="label">Add Test</span> </div> <div class="default"> Build a suite of tests that your expression should (or should not) match. <p>Create new tests with the 'Add Test' button. Click a test to edit the name, type, & text.</p> </div> </div> </article></section> <section class="tools"> <header> <h1>Tools</h1> <ul class="segcontrol toollist"></ul> <svg class="small icon max"><use xlink:href="#close"><title>Toggle tools panel</title></use></svg> </header> <article> <svg class="icon help"><use xlink:href="#help"></use></svg> <div class="inputtool"> <div class="editor"></div> <div class="result"></div> </div> <div class="content"></div> </article> </section> </div> </div> </div> <div id="library" style="display:none;"> <div id="tooltip" class="tooltip"> <svg class="tip"><use xlink:href="#dropdown"></use></svg> <div class="content"></div> </div> <div id="tooltip-flavor"> <header> <h1>RegEx Engine</h1> <svg class="icon help"><use xlink:href="#help"></use></svg> </header> <hr> <ul class="list"></ul> </div> <div id="tooltip-flags"> <header> <h1>Expression Flags</h1> <svg class="icon help"><use xlink:href="#help"></use></svg> </header> <hr> <ul class="list"></ul> </div> <div id="tooltip-testtypes"> <ul class="list"></ul> </div> <div id="tooltip-signin"> <div class="signin"> <header> <h1>Sign In</h1> <svg class="icon help"><use xlink:href="#help"></use></svg> </header> <hr> <div class="content"> Sign in to persist favorites &amp; patterns. Click the help icon above for info. <br><br> Any unsaved changes will be lost. Saved patterns &amp; favorites will be migrated to your account. </div> <hr> <ul class="list"></ul> </div> <div class="signout"> <header> <h1>Sign Out</h1> </header> <hr> <div class="content"> You are currently signed in as <b class="username">--</b> via <b class="type">--</b>. <br><br> <span class="signoutbtn">Sign out.</span> </div> </div> <div class="distract"> <svg class="icon distractor anim-spin"><use xlink:href="#distractor"></use></svg> One moment... </div> </div> <div id="cheatsheet"> <table class="cheatsheet"> <tr><th colspan="2" data-id="charclasses">Character classes</th></tr> <tr><td>.</td><td>any character except newline</td></tr> <tr><td>\w \d \s</td><td>word, digit, whitespace</td></tr> <tr><td>\W \D \S</td><td>not word, digit, whitespace</td></tr> <tr><td>[abc]</td><td>any of a, b, or c</td></tr> <tr><td>[^abc]</td><td>not a, b, or c</td></tr> <tr><td>[a-g]</td><td>character between a & g</td></tr> <tr><th colspan="2" data-id="anchors">Anchors</th></tr> <tr><td>^abc$</td><td>start / end of the string</td></tr> <tr><td>\b \B</td><td>word, not-word boundary</td></tr> <tr><th colspan="2" data-id="escchars">Escaped characters</th></tr> <tr><td>\. \* \\</td><td>escaped special characters</td></tr> <tr><td>\t \n \r</td><td>tab, linefeed, carriage return</td></tr> <tr><th colspan="2" data-id="groups">Groups & Lookaround</th></tr> <tr><td>(abc)</td><td>capture group</td></tr> <tr><td>\1</td><td>backreference to group #1</td></tr> <tr><td>(?:abc)</td><td>non-capturing group</td></tr> <tr><td>(?=abc)</td><td>positive lookahead</td></tr> <tr><td>(?!abc)</td><td>negative lookahead</td></tr> <tr><th colspan="2" data-id="quants">Quantifiers & Alternation</th></tr> <tr><td>a* a+ a?</td><td>0 or more, 1 or more, 0 or 1</td></tr> <tr><td>a{5} a{2,}</td><td>exactly five, two or more</td></tr> <tr><td>a{1,3}</td><td>between one & three</td></tr> <tr><td>a+? a{2,}?</td><td>match as few as possible</td></tr> <tr><td>ab|cd</td><td>match ab or cd</td></tr> </table> </div> <div id="community" class="community"> <header> <div class="label name"></div> <div> <svg class="icon favorites"><use xlink:href="#favorites"><title>Favorite (add to My Patterns)</title></use></svg> <svg class="icon share"><use xlink:href="#share"><title>Load & open pattern settings</title></use></svg> </div> </header> <div class="actions list"> <div class="link row"> <svg class="icon link"><use
// first param false indicates a local init.
// php passes either a pattern object, or null.
regexr.init(false, {
// local test user:
userId: 111,
authenticated: true,
username: "gskinner",
author: "grantskinner",
type: "temporary"
}, {
"PCREVersion": "8.38 2015-11-23",
"PHPVersion": "7.0.22-0ubuntu0.16.04.1"
}); </script> </body> </html>