From f79ab86a2c3cff5884bc40127f424ff1d9641fb2 Mon Sep 17 00:00:00 2001 From: "Rico Sta. Cruz" Date: Sun, 24 Mar 2019 07:38:52 +0800 Subject: [PATCH] regexp: Update formatting --- regexp.md | 71 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 38 insertions(+), 33 deletions(-) diff --git a/regexp.md b/regexp.md index 6a02e7571..183a73188 100644 --- a/regexp.md +++ b/regexp.md @@ -5,56 +5,61 @@ layout: 2017/sheet weight: -1 authors: - github: rizqyhi -updated: 2018-10-26 +updated: 2019-03-24 description: | Basic cheatsheets for regular expression --- -### Character Classes +## -| Pattern | Description | -| --- | --- | -| `.` | Any character, except newline | -| `\w` | Word | -| `\d` | Digit | -| `\s` | Whitespace | -| `\W` | Not word | -| `\D` | Not digit | -| `\S` | Not whitespace | -| `[abc]` | Any of a, b, or c | +{: .-three-column} + +### Character classes + +| Pattern | Description | +| ------- | ------------------------------ | +| `.` | Any character, except newline | +| `\w` | Word | +| `\d` | Digit | +| `\s` | Whitespace | +| `\W` | Not word | +| `\D` | Not digit | +| `\S` | Not whitespace | +| `[abc]` | Any of a, b, or c | | `[a-e]` | Characters between `a` and `e` | -| `[1-9]` | Digit between `1` and `9` | +| `[1-9]` | Digit between `1` and `9` | ### Anchors -| Pattern | Description | -| --- | --- | -| `^abc` | Start with `abc` | -| `abc$` | End with `abc` | +| Pattern | Description | +| ------- | ---------------- | +| `^abc` | Start with `abc` | +| `abc$` | End with `abc` | -### Escaped Characters +### Escaped characters -| Pattern | Description | -| --- | --- | +| Pattern | Description | +| ---------- | -------------------------------------- | | `\. \* \\` | Escape special character used by regex | -| `\t` | Tab | -| `\n` | Newline | -| `\r` | Carriage return | +| `\t` | Tab | +| `\n` | Newline | +| `\r` | Carriage return | ### Groups -| Pattern | Description | -| --- | --- | +| Pattern | Description | +| ------- | ------------- | | `(abc)` | Capture group | ### Quantifiers -| Pattern | Description | -| --- | --- | -| `a*` | Match 0 or more | -| `a+` | Match 1 or more | -| `a?` | Match 0 or 1 | -| `a{5}` | Match exactly 5 | -| `a{,3}` | Match up to 3 | -| `a{3,}` | Match 3 or more | +| Pattern | Description | +| -------- | --------------------- | +| `a*` | Match 0 or more | +| `a+` | Match 1 or more | +| `a?` | Match 0 or 1 | +| `a{5}` | Match exactly 5 | +| `a{,3}` | Match up to 3 | +| `a{3,}` | Match 3 or more | | `a{1,3}` | Match between 1 and 3 | +