I have a text object that I would like to extract only consecutive words that begin with capital letters (for example , John Rye).I tried to use regmatches() and gregexpr() but I get an error.How can I solve this issue?

```
txt<-"This is John Rye walking."

regmatches(txt, gregexpr('(.*)\s(.*)', txt, perl=T))[[1]]
Error: '\s' is an unrecognized escape in character string starting "'(.*)\s"

```

I also tried:

```
regmatches(txt, gregexpr('(^[A-Z][-a-zA-Z]+$)', txt, perl=T))[[1]]

```

but got this result:

```
character(0)

```