OSDN Git Service

Regular updates
[twpd/master.git] / regexp.md
index 3afbf1c..ecf9fff 100644 (file)
--- a/regexp.md
+++ b/regexp.md
@@ -5,14 +5,15 @@ layout: 2017/sheet
 weight: -1
 authors:
   - github: rizqyhi
+  - github: izzergh
+  - github: kolapsys
   - github: samtrion
 updated: 2019-11-14
 description: |
   Basic cheatsheets for regular expression
 ---
 
-##
-
+## RegExp
 {: .-three-column}
 
 ### Character classes
@@ -33,10 +34,18 @@ description: |
 
 ### Anchors
 
-| Pattern | Description      |
-| ------- | ---------------- |
-| `^abc`  | Start with `abc` |
-| `abc$`  | End with `abc`   |
+| Pattern | Description             |
+| ------- | ----------------------- |
+| `\G`    | Start of match          |
+| `^`     | Start of string         |
+| `$`     | End of string           |
+| `\A`    | Start of string         |
+| `\Z`    | End of string           |
+| `\z`    | Absolute end of string  |
+| `\b`    | A word boundry          |
+| `\B`    | Non-word boundry        |
+| `^abc`  | Start with `abc`        |
+| `abc$`  | End with `abc`          |
 
 ### Escaped characters
 
@@ -49,9 +58,12 @@ description: |
 
 ### Groups
 
-| Pattern | Description   |
-| ------- | ------------- |
-| `(abc)` | Capture group |
+| Pattern   | Description                    |
+| --------- | ------------------------------ |
+| `(abc)`   | Capture group                  |
+| `(a|b)`   | Match `a` or `b`               |
+| `(?:abc)` | Match `abc`, but don't capture |
+
 
 ### Quantifiers
 
@@ -65,3 +77,12 @@ description: |
 | `a{3,}`  | Match 3 or more       |
 | `a{1,3}` | Match between 1 and 3 |
 
+### Lookahead & Lookbehind
+
+| Pattern      | Description                               |
+| ---          | ---                                       |
+| `a(?=b)`     | Match `a` in `baby` but not in `bay`      |
+| `a(?!b)`     | Match `a` in `Stan` but not in `Stab`     |
+| ---          | ---                                       |
+| `(?<=a)b`    | Match `b` in `crabs` but not in `cribs`   |
+| `(?<!a)b`    | Match `b` in `fib` but not in `fab`       |