Question: Visual Studio Installer states that it is a best practice to install each file as an installer component. The heat utility provided with Wix also seems to follow the practice of putting every file in its own component.

InstallShield's component wizard uses InstallShield's setup best practice of placing portable executable files in their own component but groups all other files (e.g. unversioned files) by the common destination folder.

The advantage of practice one (each file in its own component) is that each file is set up as a key file which is important if you want these files to trigger repairs. It also allows automation of creating the components (e.g. heat) easier since you are creating a component for each file.

The disadvantages of practice one include the overhead of managing so many components and the bloating of the registry after the application is installed. 

An advantage of practice 2 could be seen in an install that installs hundreds of graphics files to one directory. If you do not care about repair functionality, is there any reason to create hundreds of components for this install?

These 2 different practices are conflicting and I want to know which one that people actually use and why.

Answer: 
It is not possible for a single regex match operation to be discontinuous.

You could use two capturing groups:

`(.*)middle(.*)`

Then concatenate the contents of capturing groups 1 and 2 after the match.

You may wish to enable the "dot also matches newline" option in your parser.  

See for example [Java's DOTALL](http://download.oracle.com/javase/1.4.2/docs/api/java/util/regex/Pattern.html#DOTALL), [.NET's Singleline](http://msdn.microsoft.com/en-us/library/yd1hzczs.aspx#Singleline), [Perl's `s`](http://perldoc.perl.org/perlre.html#Modifiers), etc.
Positive lookaround is the way to go:

```
/^(.+)(?=middle)/ -- gets everything before middle, not including middle

```

and

```
/(?!middle)(.+)$/ -- gets everything after middle, not including middle

```

Then you just merge the results of both