mirror of
https://github.com/The-Art-of-Hacking/h4cker.git
synced 2024-12-18 04:04:34 -05:00
76 lines
2.9 KiB
Markdown
76 lines
2.9 KiB
Markdown
# Regular Expression Cheat Sheets and Resources
|
|
- [ Regular Expression Cheat Sheet](https://web.mit.edu/hackl/www/lab/turkshop/slides/regex-cheatsheet.pdf)
|
|
- [Quick-Start: Regex Cheat Sheet](https://www.rexegg.com/regex-quickstart.html)
|
|
- [RegexR - Generate Regular Expressions](https://regexr.com)
|
|
- [RegexOne Exercises](https://regexone.com)
|
|
- [Regex Crossword](https://regexcrossword.com)
|
|
- [Regex101](https://regex101.com/)
|
|
|
|
## Quick Regex Reference
|
|
|
|
<table border="1" cellspacing="0" cellpadding="8">
|
|
<tbody>
|
|
<tr>
|
|
<th>Character</th>
|
|
<th>Meaning</th>
|
|
<th>Example</th>
|
|
</tr>
|
|
<tr>
|
|
<td class="sc">*</td>
|
|
<td>Match <strong>zero, one or more</strong> of the previous</td>
|
|
<td><code>Ah*</code> matches "<code>Ahhhhh</code>" or "<code>A</code>"</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="sc">?</td>
|
|
<td>Match <strong>zero or one</strong> of the previous</td>
|
|
<td><code>Ah?</code> matches "<code>Al</code>" or "<code>Ah</code>"</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="sc">+</td>
|
|
<td>Match <strong>one or more</strong> of the previous</td>
|
|
<td><code>Ah+</code> matches "<code>Ah</code>" or "<code>Ahhh</code>" but not "<code>A</code>"</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="sc">\</td>
|
|
<td>Used to <strong>escape</strong> a special character</td>
|
|
<td><code>Hungry\?</code> matches "<code>Hungry?</code>"</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="sc">.</td>
|
|
<td>Wildcard character, matches <strong>any</strong> character</td>
|
|
<td><code>do.*</code> matches "<code>dog</code>", "<code>door</code>", "<code>dot</code>", etc.</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="sc">( )</td>
|
|
<td><strong>Group</strong> characters</td>
|
|
<td>See example for <code>|</code></td>
|
|
</tr>
|
|
<tr>
|
|
<td class="sc">[ ]</td>
|
|
<td>Matches a <strong>range</strong> of characters</td>
|
|
<td><code>[cbf]ar</code> matches "car", "bar", or "far"<br /><code>[0-9]+</code> matches any positive integer<br /><code>[a-zA-Z]</code> matches ascii letters a-z (uppercase and lower case)<br /><code>[^0-9]</code> matches any character not 0-9.</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="sc">|</td>
|
|
<td>Matche previous <strong>OR</strong> next character/group</td>
|
|
<td><code>(Mon|Tues)day</code> matches "Monday" or "Tuesday"</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="sc">{ }</td>
|
|
<td>Matches a specified <strong>number of occurrences</strong> of the previous</td>
|
|
<td><code>[0-9]{3}</code> matches "315" but not "31"<br /><code>[0-9]{2,4}</code> matches "12", "123", and "1234"<br /><code>[0-9]{2,}</code> matches "1234567..."</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="sc">^</td>
|
|
<td><strong>Beginning</strong> of a string. Or within a character range <code>[]</code> negation.</td>
|
|
<td><code>^http</code> matches strings that begin with http, such as a url.<br /><code>[^0-9]</code> matches any character not 0-9.</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="sc">$</td>
|
|
<td><strong>End</strong> of a string.</td>
|
|
<td><code>ing$</code> matches "exciting" but not "ingenious"</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<p> </p>
|