How so? I have been getting much more comfortable with it lately, but I am curious what downsides there are
Please correct my English.
The lemming formerly known as:
- 1 Post
- 10 Comments
It doesn’t make sense. I understand it, but it doesn’t make sense.
Are you just referring to how Python uses the English
and
/or
instead of the more common&&
/||
? I think what the user above you was talking about was Lua’s strange ternary syntax usingand
/or
.
SatyrSack@lemmy.sdf.orgto Programmer Humor@programming.dev•Fox news trying to explain github.14·1 month agoA little less formal than an e-mails.
For when you want to delete everything in the root directory, but absolutely need to keep the directory itself.
You can open me in Vim, Greg. Am I a file?
What is being implied here? That Website A encourages you to download an image from them in WEBP format, but you cannot then upload that image to Websites B through Z because those sites do not support WEBP?
SatyrSack@lemmy.sdf.orgto Today I Learned@lemmy.world•TIL the generic but world famous 'Happy Birthday to You' song was actually copyrighted until 2016English11·2 months ago30 Rock did it the other way around while also poking fun at the trope itself
Here is my cheatsheet that has been very helpful. Obviously, this will not teach you how RegEx works, but is a good quick reference when I forget the exact syntax for something.
RegExp
Character classes
.
\w
\d
\s
\W
\D
\S
[abc]
[a-e]
a
ande
[1-9]
1
and9
[[:print:]]
[^abc]
a
,b
orc
Anchors
\G
^
$
\A
\Z
\z
\b
\B
^abc
abc
abc$
abc
For multiline patterns (
m
flag),^
and$
will act as start and end of line.Escaped characters
\. \* \\
\t
\n
\r
Groups
(abc)
(a|b)
a
orb
(?:abc)
abc
, but don’t capture\1
Quantifiers
a*
a+
a?
a{5}
a{,3}
a{3,}
a{1,3}
Lookahead & Lookbehind
a(?=b)
a
inbaby
but not inbay
a(?!b)
a
inStan
but not inStab
(?<=a)b
b
incrabs
but not incribs
(?<!a)b
b
infib
but not infab
(?<![a-z])abc(?![a-z])
abc
without any letters before/afterRaw Markdown
# RegExp ## 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` | | `[[:print:]]` | Any printable character including spaces | | `[^abc]` | Any character except `a`, `b` or `c` | ## Anchors | 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 boundary | | `\B` | Non-word boundary | | `^abc` | Start with `abc` | | `abc$` | End with `abc` | For multiline patterns (`m` flag), `^` and `$` will act as start and end of line. ## Escaped characters | Pattern | Description | | ---------- | -------------------------------------- | | `\. \* \\` | Escape special character used by regex | | `\t` | Tab | | `\n` | Newline | | `\r` | Carriage return | ## Groups | Pattern | Description | | --------- | -------------------------------------------------------- | | `(abc)` | Capture group | | `(a\|b)` | Match `a` or `b` | | `(?:abc)` | Match `abc`, but don't capture | | `\1` | Substituted with text matched of the 1st capturing 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 | | `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` | | `(?<![a-z])abc(?![a-z])` | Match `abc` without any letters before/after |