aqString.Insert Method

Applies to TestComplete 14.92, last modified on September 16, 2021

Description

Use the Insert method to insert a string at a specific position within another string.

Declaration

aqString.Insert(InputString, InsertString, InsertPosition)

InputString [in]    Required    String    
InsertString [in]    Required    String    
InsertPosition [in]    Required    Integer    
Result String

Applies To

The method is applied to the following object:

Parameters

The method has the following parameters:

InputString

The source string.

InsertString

The string to be inserted into InputString.

InsertPosition

A zero-based position of the insertion point. Possible values are 0 through the length of InputString. 0 means that InsertString will be inserted at the beginning of the InputString. The value equal to the length of InputString means that the InsertString will be appended to the end of InputString.

Result Value

A copy of the InputString string with the InsertString inserted at the specified position.

Example

The code below inserts a substring to the certain position of the specified string.

JavaScript, JScript

function InsertingSubString()
{
  var Str = "12389";
  var SubStr = "4567";
  var StartPos = 3;
  var Res = aqString.Insert( Str, SubStr, StartPos );
  
  Log.Message(Res); // Posts "123456789"
}

Python

def InsertingSubString():
  Str = "12389"
  SubStr = "4567"
  StartPos = 3
  Res = aqString.Insert(Str, SubStr, StartPos)
  Log.Message(Res) #Posts "123456789"

VBScript

Sub InsertingSubString

  Str = "12389"
  SubStr = "4567"
  StartPos = 3
  Res = aqString.Insert( Str, SubStr, StartPos )
  
  Log.Message(Res) ' Posts "123456789"
  
End Sub

DelphiScript

function InsertingSubString;
var Str, SubStr, StartPos, Res;
begin
  Str := '12389';
  SubStr := '4567';
  StartPos := 3;
  Res := aqString.Insert( Str, SubStr, StartPos );
  
  Log.Message(Res); // Posts '123456789'
end;

C++Script, C#Script

function InsertingSubString()
{
  var Str = "12389";
  var SubStr = "4567";
  var StartPos = 3;
  var Res = aqString["Insert"]( Str, SubStr, StartPos );
  
  Log["Message"](Res); // Posts "123456789"
}

See Also

Working With Strings
Concat Method
Find Method
Remove Method
Replace Method

Highlight search results