Question: My sample string:

```
 a ghgduysgd a fdferfdf a bvfxbgdf a gdfgdfg

```

I need to find all the contents between a's.

I have `(?<=a).*` But it matches all the contents after a. But I want to find between a.

First iteration: `ghgduysgd`

Second iteration: `fdferfdf`

I want to get data like the above for the manipulation. can you help with regex?

Answer: 
You can try regex like this (and ignore the first value)

```
String path = "a ghgduysgd a fdferfdf a bvfxbgdf a gdfgdfg";
String[] arr = path.split("(\\s+)?a(\\s+|$)"); // split based on a preceeded and followed by space
for (String s : arr) {
    System.out.println(s);
}

```

O/P :

```
// Empty String here. Since your String starts with a
ghgduysgd
fdferfdf
bvfxbgdf
gdfgdfg

```
You could split the String where there is an "a" and then trim the spaces and save it in an ArrayList. Then if you want to print the whole word you could use Stringbuilder to concatenate the Strings.

```
   String word="a ghgduysgd a fdferfdf a bvfxbgdf a gdfgdfg";
        List<String> list=new ArrayList<String>();
        list= Arrays.asList(word.split("a")); 
        StringBuilder sb = new StringBuilder();
        for(String item: list){
            item.trim();
        System.out.println(item);
        sb.append(item);
        }

        System.out.println(sb);

```