Skip to content

Commit d2836b4

Browse files
Merge pull request #7172 from dyadav7/user/deepyadav/extract
Updated extract example
2 parents 73ed0fb + 4a49ba0 commit d2836b4

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

data-explorer/kusto/query/extract-function.md

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,21 +40,27 @@ The following example extract the username, email, age from the string. The [reg
4040

4141
:::moniker range="azure-data-explorer"
4242
> [!div class="nextstepaction"]
43-
> <a href="https://dataexplorer.azure.com/clusters/help/databases/Samples?query=H4sIAAAAAAAAA8tJLVEISa0oUbBVUAotTi2yUvDKz8hzyU%2FVUXDNTczMsVLIAvJT8lMdUisScwtyUvWS83N1FBzTU60UjCyVrLkKijLzShRAWv0Sc1OBxgANK0pMLtGAGqcRHacTq62ppKNgqAO2SVOHC2yyZwqSYgclqG0aMcHamjooqoF2oaiMSdEGyhtA5QFR4bA2wQAAAA%3D%3D" target="_blank">Run the query</a>
43+
> <a href="https://dataexplorer.azure.com/clusters/help/databases/Samples?query=H4sIAAAAAAAAA22OPwvCMBDF93yKI1NCD%2FEPDlaECjro4KJOrUpsjlJIqrRBOvjhTW0EBW857vF%2B954hBxetnIIFdMupqyFxoNbF0Li6rArJUsaPDdUxbJWlBmFtVWnClVCr7N3QIL9ZhGVBMYxnHD%2FESj1KHfTJlLPTnPVpT%2BYjqNLQ%2BXb%2Bk8%2F3Sq1yJwIr0jOeIskRRghdI4kM%2Bnk32OgvJuGhlcj2kcR%2FkC%2FxA2Q68rZhsL0AlTcJ%2BAkBAAA%3D" target="_blank">Run the query</a>
4444
::: moniker-end
4545

4646
```kusto
47-
let Text = "User: JohnDoe, Email: [email protected], Age: 29";
48-
print UserName = extract("User: ([^,]+)", 1, Text),
49-
EmailId = extract(@"Email: (\S+),", 1, Text),
50-
Age = extract(@"\d+", 0, Text)
47+
let _data = datatable(Text: string)
48+
[
49+
"User: James, Email: [email protected], Age: 29",
50+
"User: David, Age: 35"
51+
];
52+
_data |
53+
extend UserName = extract("User: ([^,]+)", 1, Text),
54+
EmailId = extract(@"Email: (\S+),", 1, Text),
55+
Age = extract(@"\d+", 0, Text)
5156
```
5257

5358
**Output**
5459

55-
| UserName | EmailId | Age |
56-
| --- | --- | --- |
57-
| JohnDoe | [email protected] | 29 |
60+
| Text | `UserName` | `EmailId` | `Age` |
61+
| -- | --- | --- | --- |
62+
| User: James, Email: [email protected], Age: 29 | James | [email protected] | 29 |
63+
| User: David, Age: 35 | David | | 35 |
5864

5965
The following example extracts the month from the string `Dates` and returns a table with the date string and the month as int type.
6066

@@ -77,7 +83,7 @@ Dates
7783

7884
**Output**
7985

80-
| DateString | Month |
86+
| DateString | `Month` |
8187
| --- | --- |
8288
| 15-12-2024 | 12 |
8389
| 21-07-2023 | 7 |

0 commit comments

Comments
 (0)