Question: Today i've deployed my client react app to Azure App Service. The problem is, that instead of displaying site im interested in, it returns structure of wwwroot. Even if I change directory to /src/App.js it return code of the App. What is the problem?

[![enter image description here](https://i.stack.imgur.com/t1bv5.png)](https://i.stack.imgur.com/t1bv5.png)

Answer: 
You can match the title followed by 2 newlines, and for the body match all lines that are not a title pattern using 2 capture groups instead of splitting.

```
^([A-Z][a-z]*(?:[^\S\n]+[A-Z][a-z]*)*)\n\n((?:(?![A-Z][a-z]+(?:[^\S\n]+[A-Z][a-z]*)*$).*(?:\n|$))+)

```

* `^` Start of string
* `(` Capture group 1
	+ `[A-Z][a-z]*` Match an uppercase char and optional lower case chars to also match for example just `A`
	+ `(?:[^\S\n]+[A-Z][a-z]*)*` Optionally repeat 1+ spaces and the same pattern as before
* `)` Close group
* `\n\n` Match 2 newlines
* `(` Capture group 2
	+ `(?:` Non capture group
		- `(?![A-Z][a-z]+(?:[^\S\n]+[A-Z][a-z]*)*$)` Negative lookahead, assert that the line is not a title pattern
		- `.*` If the previous assertion it true, match the whole line
		- `(?:\n|$)` Match either a newline or the end of the string
	+ `)+` Close the non capture group and repeat 1 or more times
* `)` Close group 2

See a [regex demo](https://regex101.com/r/srCm5r/1) and a [Python demo](https://ideone.com/wgwN3s).

```
import re

pattern = r"^([A-Z][a-z]*(?:[^\S\n]+[A-Z][a-z]*)*)\n\n((?:(?![A-Z][a-z]+(?:[^\S\n]+[A-Z][a-z]*)*$).*(?:\n|$))+)"

s = ("This Is A Title\n\n"
    "This is where the body starts.\n\n"
    "And this is more body.")

print(re.findall(pattern, s))

```

Output

```
[('This Is A Title', 'This is where the body starts.\n\nAnd this is more body.')]

```
Suppose you have this text:

```
txt='''\
This Is A Title

This is where the body starts.
more body

Not a title -- body!

This Is Another Title

This is where the body starts.

The End
'''

```

You can use [This Regex](https://regex101.com/r/Xeqt0H/1) and separate titles (as you have defined them) from body:

```
import re
pat=r"((?=^(?:[A-Z][a-z]*[ \t]*)+$).*(?:\n\n|\n?\Z))|([\s\S]*?(?=^(?:[A-Z][a-z]*[ \t]*)+$))"

>>> re.findall(pat, txt, flags=re.M)
[('This Is A Title\n\n', ''), ('', 'This is where the body starts.\nmore body\n\nNot a title -- body!\n\n'), ('This Is Another Title\n\n', ''), ('', 'This is where the body starts.\n\n'), ('The End\n', '')]

```

---

As The fourth bird helpfully states in comments, the first lookahead can be eliminated:

```
(^(?:[A-Z][a-z]*[ \t]*)+$)(?:\n\n|\n*\Z)|([\s\S]*?(?=^(?:[A-Z][a-z]*[ \t]*)+$))

```

[Demo](https://regex101.com/r/UaJRpK/1)