Question: I have a dynamically generated PDF that I wish to download to the harddrive. The file download is started by the vb.net code:

```
WebBrowser1.Navigate("javascript:fnSubmitPDFForm('modalDivpdf')")

```

and I currently get the normal internet explorer 'File Download' window with the Open Save Cancel options. I would like to specifiy a folder and filename and automatically download the PDF. Is this possible?

Here is a better example of a link that induces the 'File Download' window. I'd like to automatically save the PDF:

```
WebBrowser1.Navigate("http://www2.hungryhorse.co.uk/index.php/download_file/view/838/71/")

```

Thanks

Answer: 
Your pattern `\(.*?\)` matches a `(` and will then find the first `)` (and everything in between): how would the pattern "understand" to match balanced parenthesis?

However, you could make use of PHP's recursive pattern:

```
$string = "Hustlin' ((Remix) Album Version (Explicit)) with (a(bbb(ccc)b)a) speed!";
echo preg_replace("/\(([^()]|(?R))*\)/", "", $string) . "\n";

```

would print:

```
Hustlin'  with  speed!
```

A short break down of the pattern:

```
\(         # match a '('
(          # start match group 1
  [^()]    #   any char except '(' and ')'
  |        #   OR
  (?R)     #   match the entire pattern recursively
)*         # end match group 1 and repeat it zero or more times
\)         # match a ')'

```
Make a simple loop with regex replacement inside.

Replace only first occurrence of 

```
/\([^()]*\)/

```

with empty string and repeat that until no match found.