LineSeparators Property

Applies to TestComplete 15.63, last modified on April 23, 2024

Description

Use the RegExpr.LineSeparators to specify which characters will be treated as line separators. Single-character line separators are used mainly on Unix-like operating systems. To get or set a double-character line separator use the RegExpr.LinePairedSeparator property.

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

Declaration

RegExprObj.LineSeparators

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

The string that contains characters treated as line breaks.

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 a new character to be treated as a line break and posts a line separated by the character 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 a character that is treated as a line break
  MyRegExpr.LineSeparator := '*';
  // 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 test log
        Log.Message(ResStr);
      until not MyRegExpr.ExecNext
    end;
end;

See Also

Using Regular Expressions in Scripts
Using Regular Expressions in Scripts
InputString Property
LinePairedSeparator Property
SpaceChars Property
WordChars Property

Highlight search results