You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/src/markdown/fnmatch.md
+14-14Lines changed: 14 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -22,7 +22,7 @@ Pattern | Meaning
22
22
`[seq]` | Matches any character in seq.
23
23
`[!seq]` | Matches any character not in seq. Will also accept character exclusions in the form of `[^seq]`.
24
24
`[[:alnum:]]` | POSIX style character classes inside sequences. See [POSIX Character Classes](#posix-character-classes) for more info.
25
-
`\` | Escapes characters. If applied to a meta character, it will be treated as a normal character.
25
+
`\` | Escapes characters. If applied to a meta character or non-meta characters, the character will be treated as a literal character. If applied to another escape, the backslash will be a literal backslash.
26
26
`!` | When used at the start of a pattern, the pattern will be an exclusion pattern. Requires the [`NEGATE`](#negate) flag. If also using the [`MINUSNEGATE`](#minusnegate) flag, `-` will be used instead of `!`.
27
27
`?(pattern_list)` | The pattern matches if zero or one occurrences of any of the patterns in the `pattern_list` match the input string. Requires the [`EXTMATCH`](#extmatch) flag.
28
28
`*(pattern_list)` | The pattern matches if zero or more occurrences of any of the patterns in the `pattern_list` match the input string. Requires the [`EXTMATCH`](#extmatch) flag.
@@ -63,15 +63,15 @@ a list of patterns. It will return a boolean indicating whether the file name wa
Copy file name to clipboardExpand all lines: docs/src/markdown/glob.md
+36-18Lines changed: 36 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -23,7 +23,7 @@ Pattern | Meaning
23
23
`[seq]` | Matches any character in seq.
24
24
`[!seq]` | Matches any character not in seq. Will also accept character exclusions in the form of `[^seq]`.
25
25
`[[:alnum:]]` | POSIX style character classes inside sequences. See [POSIX Character Classes](#posix-character-classes) for more info.
26
-
`\` | Escapes characters. If applied to a meta character, it will be treated as a normal character.
26
+
`\` | Escapes characters. If applied to a meta character or non-meta characters, the character will be treated as a literal character. If applied to another escape, the backslash will be a literal backslash.
27
27
`!` | When used at the start of a pattern, the pattern will be an exclusion pattern. Requires the [`NEGATE`](#negate) flag. If also using the [`MINUSNEGATE`](#minusnegate) flag, `-` will be used instead of `!`.
28
28
`?(pattern_list)` | The pattern matches if zero or one occurrences of any of the patterns in the `pattern_list` match the input string. Requires the [`EXTGLOB`](#extglob) flag.
29
29
`*(pattern_list)` | The pattern matches if zero or more occurrences of any of the patterns in the `pattern_list` match the input string. Requires the [`EXTGLOB`](#extglob) flag.
@@ -152,6 +152,24 @@ Pattern | Meaning
152
152
153
153
--8<-- "posix.md"
154
154
155
+
## Windows Separators
156
+
157
+
On Windows, it is not required to use backslashes for path separators as `/` will match path separators for all systems.
158
+
The following will work on Windows and Linux/Unix systems.
159
+
160
+
```python
161
+
glob.glob('docs/.*')
162
+
```
163
+
164
+
With that said, you can match Windows separators with backslashes as well. Keep in mind that Wildcard Match allows
165
+
escaped characters in patterns, so to match a literal backslash separator, you must escape the backslash. It is advised
166
+
to use raw strings when using backslashes to make the patterns more readable, but either of the below will work.
167
+
168
+
```python
169
+
glob.glob(r'docs\\.*')
170
+
glob.glob('docs\\\\.*')
171
+
```
172
+
155
173
## Multi-Pattern Limits
156
174
157
175
Many of the API functions allow passing in multiple patterns or using either [`BRACE`](#brace) or
@@ -180,23 +198,23 @@ file system returning matching files.
0 commit comments