Skip to content

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
sharpchen committed Jun 18, 2024
1 parent 6f2941d commit adfc1ab
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Regex is case-sensitive by default, to ignore case, add leading `(?i)`.

:::code-group

```regex
```regexp
(?i)ascii
```

Expand All @@ -21,6 +21,6 @@ _ = new Regex(@"ascii", RegexOptions.IgnoreCase)
To partially ignore case, close partial regex using `(?i)<regex>(?-i)`
The following matches `ASCIIascciiascii` but not `asciiasciiASCII`

```regex
```regexp
ASCII(?i)aScIi(?-i)ascii
```
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

Create a *character class* to match one occurrence inside a `[]`

```regex
```regexp
c[ae]l[ae]nd[ae]r
```

Expand All @@ -14,7 +14,7 @@ Create a certain range using `-`

Match one of hexadecimal characters:

```regex
```regexp
[a-fA-F0-9]
```

Expand All @@ -26,7 +26,7 @@ Negate a range using leading `^`

Match Non-hexadecimal characters:

```regex
```regexp
[^a-fA-F0-9]
```

Expand All @@ -40,13 +40,13 @@ There's four special characters may need to be escaped:

For any character that are not one of above, is not required to be escaped:

```regex
```regexp
[$()*+.?{|]
```

For `^`s not act as negation are not required to be escaped:

```regex
```regexp
[a-f^A-F\^0-9]
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
_ = new Regex(@"^abcefg$", RegexOptions.Multiline);
```

> `^` always matches after `\n`, so `\n^` is redundant
> `$` always matches before `\n`, so `$\n` is redundant
> `\A\Z` matches empty string and empty string with a single new line
> `\A\z` matches only empty string
- `^` always matches after `\n`, so `\n^` is redundant
- `$` always matches before `\n`, so `$\n` is redundant
- `\A\Z` matches empty string and empty string with a single new line
- `\A\z` matches only empty string

:::tip
Always use `\A` and `\Z` instead of `^` and `$` when to match start/end of a whole string
Expand Down

0 comments on commit adfc1ab

Please sign in to comment.