-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Wei Zhang <[email protected]>
- Loading branch information
Showing
5 changed files
with
47 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
crates/tabby/tests/snapshots/goldentests_chat__run_chat_golden_tests-2.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
--- | ||
source: crates/tabby/tests/goldentests_chat.rs | ||
expression: "golden_test(json!({\n \"seed\": 0, \"model\": \"default\", \"messages\":\n [{\n \"role\": \"user\", \"content\":\n \"How to parse email address with regex\"\n }]\n })).await" | ||
expression: "golden_test(json!({\n \"seed\": 0, \"model\": \"default\", \"messages\":\n [{ \"role\": \"user\", \"content\": \"How to parse email address with regex\" }]\n})).await" | ||
--- | ||
" Parsing an email address with regular expressions can be a complex task. Here's one possible regular expression pattern that you can use to extract the username and domain name from an email address:\n```vbnet\n^[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\\.[a-zA-Z0-9-]+)*$\n```\nThis pattern checks for the following:\n\n1. The email address starts with one or more characters that are allowed in the username, such as letters, numbers, dots, and special characters.\n2. The `@` symbol must follow the username.\n3. The domain name consists of one or more characters that are allowed in the domain name, such as letters, numbers, dots, and hyphens.\n4. The domain name is followed by an optional period and one or more characters that are allowed in the domain name.\n5. The email address ends after the domain name and any optional period and characters.\n\nHere's an example of how you can use this regular expression pattern in Python:\n```python\nimport re\n\nemail = \"[email protected]\"\nusername, domain = re.split(\"[@.]\", email)\nprint(username) # Output: example\nprint(domain) # Output: example.com\n```\nIn this example, the `re.split()` function splits the email address into two parts using the regular expression pattern. The `username` variable will contain the username (`example`), and the `domain` variable will contain the domain name (`example.com`)." | ||
" Parsing an email address with regular expressions can be a bit tricky, but it can be done using a combination of patterns and character classes. Here's an example of a regular expression that can be used to match most email addresses:\n```\n\\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Z|a-z]{2,}\\b\n```\nThis regular expression uses the following patterns:\n\n* `\\b`: This is a word boundary that matches the beginning or end of a word. It ensures that the email address is matched as a whole, not just as a part of a longer string.\n* `[A-Za-z0-9._%+-]+`: This pattern matches one or more characters that are either letters (A-Z or a-z), digits (0-9), periods (.), underscores (\\_), percent signs (%), plus signs (+), or hyphens (-). This is the local part of the email address.\n* `@`: This is the character that separates the local part from the domain name.\n* `[A-Za-z0-9.-]+\\.`: This pattern matches one or more characters that are either letters (A-Z or a-z), digits (0-9), periods (.), or hyphens (-). The period is followed by a dot to indicate that it is the end of the domain name.\n* `[A-Z|a-z]{2,}`: This pattern matches two or more letters that are either uppercase (A-Z) or lowercase (a-z). This is the top-level domain of the email address.\n* `\\b`: This pattern matches the end of the email address.\n\nNote that this regular expression is not perfect and may not match all email addresses, but it should work for most common cases." |
4 changes: 2 additions & 2 deletions
4
crates/tabby/tests/snapshots/goldentests_chat__run_chat_golden_tests.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
--- | ||
source: crates/tabby/tests/goldentests_chat.rs | ||
expression: "golden_test(json!({\n \"seed\": 0, \"model\": \"default\", \"messages\":\n [{\n \"role\": \"user\", \"content\":\n \"How to convert a list of string to numbers in python\"\n }]\n })).await" | ||
expression: "golden_test(json!({\n \"seed\": 0, \"model\": \"default\", \"messages\":\n [{\n \"role\": \"user\", \"content\":\n \"How to convert a list of string to numbers in python\"\n }]\n})).await" | ||
--- | ||
" You can convert a list of strings to numbers in Python using the built-in `list()` function. Here's an example:\n```python\nstrings = ['1', '2', '3']\nnumbers = list(map(int, strings))\nprint(numbers) # [1, 2, 3]\n```\nIn this example, we first define a list `strings` containing three string values. We then use the `map()` function to apply the `int()` function (which converts a string to an integer) to each element of the `strings` list, and the resulting list of integers is stored in the variable `numbers`. Finally, we print the `numbers` list to verify that the conversion was successful." | ||
" You can convert a list of strings to numbers in Python using the built-in `list()` function to convert the list of strings to a list of numbers, and then using the `int()` function to convert each element of the list to an integer. Here's an example:\n```\n# A list of strings\nnum_strings = ['1', '2', '3']\n\n# Convert the list of strings to a list of numbers\nnum_list = list(map(int, num_strings))\n\n# Print the list of numbers\nprint(num_list)\n```\nThis will output:\n```\n[1, 2, 3]\n```\nNote that this will only work if the strings represent integers. If the strings represent a different type of number, such as a decimal number, you will need to use a different function, such as `float()`, to convert them to a float.\n\nAlso, if you want to convert the string to a specific number type, you can use the built-in `int()` function and pass the number as an argument.\n\nFor example, to convert the string '123' to a float:\n```\nnum_string = '123'\nnum_float = float(num_string)\nprint(num_float)\n```\nThis will output:\n```\n123.0\n```\nAnd to convert the string '123' to a decimal:\n```\nnum_string = '123.45'\nnum_decimal = float(num_string)\nprint(num_decimal)\n```\nThis will output:\n```\n123.45\n```" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters