Lines

Use the controls on this settings page to edit a list of line expressions that are used in text comparisons (including, possibly, the comparison of text files performed during a folder comparison, depending on how you have configured Merge).

Line expressions are regular expressions that are applied line-by-line to text comparisons to match unimportant text that you wish Merge to ignore. This capability is useful for filtering out unimportant changes or changes that only affect the formatting within files.

Line expression list

This control contains a list of line expressions. Only those line expressions that have a check mark will be used in text comparisons. Double-click a line expression to edit its definition.

Two types of line expression are supported. The first enables you to force lines that contain a match for a regular expression to be unchanged (that is, make Merge ignore those lines entirely when comparing files). This is useful for lines that contain no-other meaningful content beyond that matched by the expression. The second type of line expression is used to ignore sequences of characters matching a regular expression within a line, instead of the entire line.

Information A line matched by the first type of line expression is shown using the fonts and colours you have configured for unchanged text. However, the linking lines relating it to text in the other file(s) are not removed and the change count shown in the status bar is not affected. The only exception to this is if every line in each of the corresponding blocks of text is matched by a line expression. In this case, the linking lines will also be removed and the change count in the status bar will be updated accordingly.

Regular expression syntax

The regular expression syntax used by Araxis Merge is the same as that used by many applications in the UNIX operating system. Regular expressions can be used to search for sequences of characters within a piece of text. They consist of simple text that will be matched literally, and special characters that have a particular meaning.

The rest of this topic contains example regular expressions. For more comprehensive information, please see the Regular Expression Reference.

Simple matches

To match lines containing the word apple:

apple

To match lines containing only the word apple:

^apple$

Matching whitespace

To match lines that are either completely empty, or that only contain whitespace (spaces and tab characters):

^[ \t]*$

Breakdown:

  • ^ Match the start of the line.
  • [ \t]* Match zero or more space or tab (\t) characters.
  • $ Match the end of the line.

Matching C++ comments

To match lines that contain only a C++ style comment (//, followed by any characters up to the end of the line), the following expression can be used:

^[ \t]*//.*$

Breakdown:

  • ^ Match the start of the line.
  • [ \t]* Match zero or more space or tab (\t) characters.
  • // Match two consecutive / characters.
  • .* Match zero or more occurrences of any character.
  • $ Match the end of the line.

Matching source code control keywords

Some version control products enable special keywords to be inserted into text files. Subversion, for example, will expand out a piece of text $Date$ so that it contains the date and time of the last check-in. When comparing different revisions of a file, lines containing these keywords will almost always be different and can be ignored. An expression to ignore the Date keyword when it appears in C++ comment lines follows:

^[ \t]*//.*\$Date:.*\$.*$

Breakdown:

  • ^ Match the start of the line.
  • [ \t]* Match zero or more space or tab (\t) characters.
  • // Match two consecutive / characters.
  • .* Match zero or more occurrences of any character.
  • \$ Match the character $, not the end of line. Putting \ before a character means that the character is treated as literal. Any special meaning it might have had as a regular expression is removed.
  • Date: Match Date:
  • .* Match zero or more occurrences of any character.
  • \$ Match the literal character $.
  • .* Match zero or more occurrences of any character.
  • $ Match the end of the line.

Related expressions:

  • ^[ \t]*//.*\$Archive:.*\$.*$
  • ^[ \t]*//.*\$Author:.*\$.*$
  • ^[ \t]*//.*\$Header:.*\$.*$
  • ^[ \t]*//.*\$JustDate:.*\$.*$
  • ^[ \t]*//.*\$Modtime:.*\$.*$
  • ^[ \t]*//.*\$Revision:.*\$.*$
  • ^[ \t]*//.*\$Workfile:.*\$.*$

Combining expressions

Several expressions can be combined in to one by using the parenthesis () and | characters:

(apple|^pear$)

Breakdown:

  • ( Begins a group of expressions.
  • apple Match lines containing the word apple.
  • | Match lines that contain matches for the previous expression (apple) or the next one (^pear$).
  • ^pear$ Match lines consisting of only the word pear.
  • ) Ends the group.

This syntax enables larger expressions like the following to be constructed:

^[ \t]*//.*\$(Date|Archive|Author|Header|JustDate|Modtime|Revision|Workfile):.*\$.*$

It is almost always better for comparison performance if expressions are made as short as possible. The example above performs significantly better than the following:

(^[ \t]*//.*\$Date:.*\$.*$)|
(^[ \t]*//.*\$Archive:.*\$.*$)|
(^[ \t]*//.*\$Author:.*\$.*$)|
(^[ \t]*//.*\$Header:.*\$.*$)|
(^[ \t]*//.*\$JustDate:.*\$.*$)|
(^[ \t]*//.*\$Modtime:.*\$.*$)|
(^[ \t]*//.*\$Revision:.*\$.*$)|
(^[ \t]*//.*\$Workfile:.*\$.*$)