Suppose I have a string like "A B C (123-456-789)", I'm wondering what's the best way to retrieve "123-456-789" from it. 

```
strsplit("A B C (123-456-789)", "\\(")
[[1]]
[1] "A B C" "123-456-789)"

```
['https://Stackoverflow.com/questions/31292853', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/3015453/']
The capture groups in `sub` will target your desired output:

```
sub('.*\\((.*)\\).*', '\\1', str1)
[1] "123-456-789"

```

Extra check to make sure I pass @akrun's extended example:

```
sub('.*\\((.*)\\).*', '\\1', str2)
[1] "123-425-478" "123-423-428" "123-423-498" "123-432-423" "124-233-848"

```
Try this also: 

```
 k<-"A B C (123-456-789)"
     regmatches(k,gregexpr("*.(\\d+).*",k))[[1]]
[1] "(123-456-789)"

```

With suggestion from @Arun: 

```
regmatches(k, gregexpr('(?<=\\()[^A-Z ]+(?=\\))', k, perl=TRUE))[[1]]

```

With suggestion from @akrun: 

```
regmatches(k, gregexpr('[0-9-]+', k))[[1]]

```