Blocks

Use the controls on this options page to edit a list of block 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).

Block expressions define blocks of lines that you wish Merge to ignore. These blocks are bounded by lines matching a starting and ending regular expression. This capability can be useful for filtering out unimportant changes or blocks of auto-generated content.

Block expression list

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

A block expression consists of a description, a beginning regular expression, and an ending regular expression. You can also choose whether or not the ignored block includes the lines matching the beginning and ending regular expressions.

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:.*\$.*$)