Question: I have bundle `A.jar` installed in OSGi and I can get this bundle using BundleContext 

`Bundle bundleA = context.getBundle()`

And a specific classloader B

How can I adding all class from `bundleA` to my classloader B

Answer: 
Regular expresion that enrico.bacis suggested *(\S.*?.\S+)\* will not work if there are filenames without characters before "." like *.project*.

Correct pattern would be:

```
(([^ .]+ +)*\S*\.\S+)

```

You can try it [here](http://regex101.com/r/eU2uW6/1).

Java program that could extract filenames will look like:

```
String patternStr = "([^ .]+ +)*\\S*\\.\\S+";
String input = "file1.txt .project file2.jpg tricky file name.txt other tricky filenames containing áéíoéáóó.gif";
Pattern pattern = Pattern.compile(patternStr, Pattern.MULTILINE);
Matcher matcher = pattern.matcher(input);
while (matcher.find()) {            
    System.out.println(matcher.group());
}

```
If there are spaces in the file names, it makes it trickier. 

If you can assume there are no dots (.) in the file names, you can use the dot to find each individual records as has been suggested.

If you can't assume there are no dots in file names, e.g. my file.new something.txt 

In this situation, I'd suggest you create a list of acceptable extentions, e.g. .doc, .jpg, .pdf etc.

I know the list may be long, so it's not ideal. Once you have done this you can look for these extensions and assume what's before it is a valid filename.