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 alrady use a lookbehind in your regex, change it to also use a lookahead:

```
(?<=a).*(?=a|$)

```

Then make the `.*` non-greedy to stop at the first available "ending" `a`:

```
(?<=a).*?(?=a|$)

```

EDIT: the `a|$` is from tobias\_k's comment below, originally it was just `a`