This endpoint works:
https://www.binance.com/api/v3/klines?symbol=BTCUSDT&interval=1h&limit=2
This endpoint will return an error:
https://www.binance.com/api/v3/klines?symbol=BTCUSDT%7CETHUSDT&interval=1h&limit=2
The regular expression ^[A-Z0-9-_.]{1,20}$
is a pattern used to validate strings, ensuring they adhere to specific rules. Let's break down each part of this regular expression:
-
^
(Caret)- Meaning: Asserts the start of the string. It ensures that the match must occur at the beginning of the string.
-
[A-Z0-9-_.]
(Character Class)- Meaning: Defines a set of allowed characters.
- Details:
A-Z
: Allows any uppercase English letter (from A to Z).0-9
: Allows any digit (from 0 to 9).-
: Allows the hyphen character-
._
: Allows the underscore character_
..
: Allows the period (dot) character.
.
-
{1,20}
(Quantifier)- Meaning: Specifies that the preceding character class must occur at least 1 time and at most 20 times.
- Details:
1
: The minimum number of characters allowed is 1.20
: The maximum number of characters allowed is 20.
-
$
(Dollar Sign)- Meaning: Asserts the end of the string. It ensures that the match must occur at the end of the string.
- Overall Pattern: The string must consist of 1 to 20 characters, where each character is either an uppercase letter (
A-Z
), a digit (0-9
), a hyphen (-
), an underscore (_
), or a period (.
). - String Boundaries: The
^
and$
ensure that the entire string must match this pattern from start to finish, with no additional characters.
"BTCUSDT"
"ABC-123"
"TOKEN_NAME"
"X-123.A"
"btc_usdt"
(contains lowercase letters, which are not allowed)"ABC!123"
(contains an exclamation mark, which is not allowed)"A"
(valid but would be an edge case at the minimum length)"TOO-LONG-VALUE-EXAMPLE"
(would be invalid if it exceeds 20 characters)
This regular expression is commonly used to validate inputs where a specific format is required, such as in API parameters, filenames, identifiers, etc.