mirror of
https://github.com/The-Art-of-Hacking/h4cker
synced 2024-11-10 05:34:12 +00:00
Update regular-expressions.md
This commit is contained in:
parent
f043214d29
commit
2cc7d511ab
1 changed files with 70 additions and 0 deletions
|
@ -4,3 +4,73 @@
|
|||
- [RegexR - Generate Regular Expressions](https://regexr.com)
|
||||
- [RegexOne Exercises](https://regexone.com)
|
||||
- [Regex Crossword](https://regexcrossword.com)
|
||||
- [Regex101](https://regex101.com/)
|
||||
|
||||
## Quick Regex Reference
|
||||
|
||||
<h2> </h2>
|
||||
<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>
|
||||
|
|
Loading…
Reference in a new issue