Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions data-explorer/kusto/query/extract-function.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,27 @@ The following example extract the username, email, age from the string. The [reg

:::moniker range="azure-data-explorer"
> [!div class="nextstepaction"]
> <a href="https://dataexplorer.azure.com/clusters/help/databases/Samples?query=H4sIAAAAAAAAA8tJLVEISa0oUbBVUAotTi2yUvDKz8hzyU%2FVUXDNTczMsVLIAvJT8lMdUisScwtyUvWS83N1FBzTU60UjCyVrLkKijLzShRAWv0Sc1OBxgANK0pMLtGAGqcRHacTq62ppKNgqAO2SVOHC2yyZwqSYgclqG0aMcHamjooqoF2oaiMSdEGyhtA5QFR4bA2wQAAAA%3D%3D" target="_blank">Run the query</a>
> <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>
::: moniker-end

```kusto
let Text = "User: JohnDoe, Email: [email protected], Age: 29";
print UserName = extract("User: ([^,]+)", 1, Text),
EmailId = extract(@"Email: (\S+),", 1, Text),
Age = extract(@"\d+", 0, Text)
let _data = datatable(Text: string)
[
"User: James, Email: [email protected], Age: 29",
"User: David, Age: 35"
];
_data |
extend UserName = extract("User: ([^,]+)", 1, Text),
EmailId = extract(@"Email: (\S+),", 1, Text),
Age = extract(@"\d+", 0, Text)
```

**Output**

| UserName | EmailId | Age |
| --- | --- | --- |
| JohnDoe | [email protected] | 29 |
| Text | `UserName` | `EmailId` | `Age` |
| -- | --- | --- | --- |
| User: James, Email: [email protected], Age: 29 | James | [email protected] | 29 |
| User: David, Age: 35 | David | | 35 |

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

Expand All @@ -77,7 +83,7 @@ Dates

**Output**

| DateString | Month |
| DateString | `Month` |
| --- | --- |
| 15-12-2024 | 12 |
| 21-07-2023 | 7 |
Expand Down