Skip to content

Commit 5ac43f7

Browse files
committed
added 3 more snippets
1 parent f701f7d commit 5ac43f7

File tree

3 files changed

+52
-0
lines changed

3 files changed

+52
-0
lines changed

snippets/regex/miscellaneous/ipv4.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
Title: IPv4
3+
Description: Matches IPv4 address
4+
Author: majvax
5+
Tags: ipv4,networking
6+
---
7+
8+
9+
```regex
10+
^((25[0-5]|2[0-4]\d|1\d{2}|\d{1,2})\.){3}(25[0-5]|2[0-4]\d|1\d{2}|\d{1,2})$
11+
12+
13+
-> Usage:
14+
123.300.0.101 ✗
15+
127.0.0.1 ✓
16+
192.168.0.1 ✓
17+
```
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
Title: Unintentional Duplication
3+
Description: Matches duplicated word in a text.
4+
Author: majvax
5+
Tags: trim
6+
---
7+
8+
9+
```regex
10+
\b(\w+)\s+\1\b
11+
12+
13+
-> Usage:
14+
I need to finish this task ✗
15+
I need to to finish this task ✓
16+
```
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
Title: Whitespace Trimmer
3+
Description: Matches leading and/or trailing whitespace.
4+
Author: majvax
5+
Tags: trim
6+
---
7+
8+
9+
```regex
10+
^\s+|\s+$
11+
12+
13+
-> Usage:
14+
(don't account for the quotation marks, it just to visualize whitespace)
15+
"Hello World" ✗
16+
" Hello World" ✓
17+
"Hello World " ✓
18+
" Hello World " ✓
19+
```

0 commit comments

Comments
 (0)