# Text.InsStr(Text, Text, Integer) Method
> Version: _Available or changed with runtime version 1.0._
Inserts a substring into a string.
## Syntax
```al
NewString :=   Text.InsStr(String: Text, SubString: Text, Position: Integer)
```
> NOTE
> This method can be invoked without specifying the data type name.
## Parameters
String
Type: text-data-type
The string into which you want to insert a substring.
SubString
Type: text-data-type
The substring that you want to insert into String.
Position
Type: ../integer/integer-data-type
Specifies where to insert SubString. Position must be greater than or equal to 1. If Position is greater than the length of String, then the result is concatenated and copied to NewString.
## Return Value
NewString
Type: text-data-type
The input string including the specified substring
## Remarks
If SubString is empty, then String is returned unchanged.
If Position is less than 1, an error is returned.
If Position is greater than the length of String, SubString is added at the end of String. For example, `InsStr("Thomas","AAA",999)` returns 'ThomasAAA'.
## Example
```al
var
    Str: Text[60];
    SubString: Text[60];
    NewString: Text[60];
    Text000: Label 'Press ENTER to continue.';
    Text001: Label 'or ESC';
    Text002: Label ' The test string before InsStr is called:>%1<';
    Text003: Label ' The resulting string after InsStr is called:>%1<';
begin
    Str := Text000;
    SubString := Text001;
    Message(Text002, Str);
    NewString := InsStr(Str, SubString, 13);
    Message(Text003, NewString);
end;
```
The first message window displays the following:
The test string before InsStr is called:
>Press ENTER to continue.\<
The second message window displays the following:
The resulting string after InsStr is called:
>Press ENTER or ESC to continue.\<
## Related information
text-data-type
Get Started with AL<../../devenv-get-started>
Developing Extensions<../../devenv-dev-overview>

Copyright (c) Microsoft Corporation. CC BY 4.0, https://creativecommons.org/licenses/by/4.0/; code samples MIT. From https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/text/text-insstr-method, MicrosoftDocs/dynamics365smb-devitpro-pb at 828b6ee (2026-11-19). Changed: includes filled in, links to this site, and for agents shortened without dropping a fact. https://jonas-paprotka.de/docs/dev-itpro/developer/methods-auto/text/text-insstr-method/
