Edit Block Expression

Use the controls in this window to edit the definition and description of a block expression. For further information about the purpose of block expressions, see Blocks.

Description

Use this field to provide a description of the block expression.

Beginning regex

This entry field contains the regular expression that matches all or part of the line that is to start the block of lines to be ignored. A summary of regular expression syntax may be found below.

Information Begin the regular expression with ^ (match start of line) and end it with $ (match end of line) if you wish the expression to match an entire line.

The status text below the entry field indicates whether the provided regular expression is syntactically correct.

Ending regex

This entry field contains the regular expression that matches all or part of the line that is to end the block of lines to be ignored. A summary of regular expression syntax may be found below.

Information Begin the regular expression with ^ (match start of line) and end it with $ (match end of line) if you wish the expression to match an entire line.

The status text below the entry field indicates whether the provided regular expression is syntactically correct.

Unchanged block includes matching beginning and ending lines

Check this option if you wish Merge to treat the beginning and ending lines matched by the provided regular expressions as part of the block of lines to be ignored. This causes Merge to ignore entirely for comparison purposes not only the contents of the block but also the beginning and ending lines.

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