[INST] Write a Java function to output all matches of a given regex inside a string./nString: "This is an example string with an address https://www.example.com."
Regex: "example\\.com" [/INST]  ###Response: Here's an example Java function to output all matches of a given regex inside a string:

```
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class RegexMatcher {
  public static void findMatches(String input, String regex) {
    Pattern pattern = Pattern.compile(regex);
    Matcher matcher = pattern.matcher(input);

    while (matcher.find()) {
      System.out.println("Match found: " + matcher.group());
    }
  }

  public static void main(String[] args) {
    String input = "This is an example string with an address https://www.example.com.";
    String regex = "example\\.com";
    findMatches(input, regex);
  }
}
```

This code defines a function called `findMatches` that takes the input string and regex as parameters. It then compiles the regex into a `Pattern` object, creates a `Matcher` object using the input string, and loops through all the matches using `matcher.find()`. For each match, it prints out the matched string using `matcher.group()`. Finally, the `main` method calls `findMatches` with the example input and regex. 

In this case, the output of running this code would be:

```
Match found: example.com
```