LinePairedSeparator Property

Applies to TestComplete 14.71, last modified on April 22, 2021

Description

Use the RegExpr.LinePairedSeparator to specify which characters will be treated as paired line separators. Paired line separators are used mainly on DOS and Windows operating systems. The string that is assigned to this property must contain exactly two characters or no characters at all. To get or set a single line separator use the RegExpr.LineSeparators property.

The default value is a carriage return (\r) and a newline (\n) -- or -- #$D#$A.

Declaration

RegExprObj.LinePairedSeparator

Read-Write Property String
RegExprObj An expression, variable or parameter that specifies a reference to a RegExpr object

Applies To

The property is applied to the following object:

Property Value

A string that contains characters treated as paired line separators.

Remarks

The ^ metacharacter matches the start of the input text and if multi-line mode is enabled, it also matches after each line break.

The $ metacharacter matches the end of the input text and if multi-line mode is enabled, it also matches before every line break.

The . metacharacter matches any character and if single-line mode is disabled, it does not match a line break.

Depending on the operating system, a line break could contain only one character (Unix) or a pair of characters (DOS/Windows). Characters that are treated as line breaks are defined by the RegExpr.LineSeparators or RegExpr.LinePairedSeparator property respectively.

Example

The following sample specifies new characters to be treated as double-character line breaks and posts lines separated by the characters to the test log.

DelphiScript

procedure LineSeparatorSample;

var
  MyRegExpr : OleVariant;
  Modifier: string;
  Input, Expr, ResStr: string;
begin

  MyRegExpr := HISUtils.RegExpr;
  Input := 'Line1@*Line2@*Line3';
  MyRegExpr.InputString := Input;
  // Enables the multiline mode
  MyRegExpr.ModifierStr := 'm';
  // Specifies the characters that are treated as double-character line breaks
  MyRegExpr.LinePairedSeparator := '@*';
  // Specifies a pattern
  MyRegExpr.Expression := '^([\w]+)*( +[\w]+)*';

  if MyRegExpr.Exec(Input) then
    begin
      repeat
        ResStr := MyRegExpr.Match[0];
        // Posts the line separated by the "@*" character to the log
        Log.Message(ResStr);
      until not MyRegExpr.ExecNext
    end;
end;

See Also

Regular Expressions Syntax
Using Regular Expressions in Scripts
InputString Property
LineSeparators Property
SpaceChars Property
WordChars Property

Highlight search results