regex
parent
d8639390da
commit
c9585666b9
|
@ -4,8 +4,12 @@ Read [Syntax](https://github.com/google/re2/wiki/Syntax).
|
||||||
|
|
||||||
Read [Golang-Regex-Tutorial](https://github.com/StefanSchroeder/Golang-Regex-Tutorial).
|
Read [Golang-Regex-Tutorial](https://github.com/StefanSchroeder/Golang-Regex-Tutorial).
|
||||||
|
|
||||||
|
Play with [Regex101](https://regex101.com/).
|
||||||
|
|
||||||
|
## Basic
|
||||||
|
|
||||||
| regex | meaning |
|
| regex | meaning |
|
||||||
| -------- | ----------------------------------------- |
|
| ------------ | ----------------------------------------- |
|
||||||
| `.` | any character, default not including `\n` |
|
| `.` | any character, default not including `\n` |
|
||||||
| `[xy]` | `x` or `y` character |
|
| `[xy]` | `x` or `y` character |
|
||||||
| `[^xy]` | not `x` and `y` character |
|
| `[^xy]` | not `x` and `y` character |
|
||||||
|
@ -21,9 +25,6 @@ Read [Golang-Regex-Tutorial](https://github.com/StefanSchroeder/Golang-Regex-Tut
|
||||||
| `\D` | not digits |
|
| `\D` | not digits |
|
||||||
| `\s` | whitespace |
|
| `\s` | whitespace |
|
||||||
| `\S` | not whitespace |
|
| `\S` | not whitespace |
|
||||||
|
|
||||||
| advanced regex | meaning |
|
|
||||||
| -------------- | ----------------------------------- |
|
|
||||||
| `(foo)` | numbered capturing group (submatch) |
|
| `(foo)` | numbered capturing group (submatch) |
|
||||||
| `(?:foo)` | non capturing group |
|
| `(?:foo)` | non capturing group |
|
||||||
| `(?:x`\|`y)` | `x` or `y` expression wrap in `()` |
|
| `(?:x`\|`y)` | `x` or `y` expression wrap in `()` |
|
||||||
|
@ -33,3 +34,23 @@ Read [Golang-Regex-Tutorial](https://github.com/StefanSchroeder/Golang-Regex-Tut
|
||||||
| ---- | ---------------- |
|
| ---- | ---------------- |
|
||||||
| `i` | case-insensitive |
|
| `i` | case-insensitive |
|
||||||
| `s` | `.` match `\n` |
|
| `s` | `.` match `\n` |
|
||||||
|
|
||||||
|
## Example
|
||||||
|
|
||||||
|
```regex
|
||||||
|
(?i)hello\sfoo
|
||||||
|
|
||||||
|
match: Hello Foo
|
||||||
|
match: heLLo fOO
|
||||||
|
```
|
||||||
|
|
||||||
|
```regex
|
||||||
|
hello\s(.+)
|
||||||
|
|
||||||
|
match: hello foo
|
||||||
|
group 1: foo
|
||||||
|
|
||||||
|
|
||||||
|
match: hello bar
|
||||||
|
group 1: bar
|
||||||
|
```
|
||||||
|
|
Loading…
Reference in New Issue