Επεξεργασία

Κοινή χρήση μέσω


replace_string()

Applies to: ✅ Microsoft FabricAzure Data ExplorerAzure MonitorMicrosoft Sentinel

Replaces all string matches with a specified string.

Deprecated aliases: replace()

To replace multiple strings, see replace_strings().

Syntax

replace_string(text, lookup, rewrite)

Learn more about syntax conventions.

Parameters

Name Type Required Description
text string ✔️ The source string.
lookup string ✔️ The string to be replaced.
rewrite string ✔️ The replacement string.

Returns

Returns the text after replacing all matches of lookup with evaluations of rewrite. Matches don't overlap.

Example

range x from 1 to 5 step 1
| extend str=strcat('Number is ', tostring(x))
| extend replaced=replace_string(str, 'is', 'was')

Output

x str replaced
1 Number is 1.000000 Number was 1.000000
2 Number is 2.000000 Number was 2.000000
3 Number is 3.000000 Number was 3.000000
4 Number is 4.000000 Number was 4.000000
5 Number is 5.000000 Number was 5.000000