Question: Suppose I have a list of string:

```
distance <- c("CHI #12 DEBRINCAT(1), Snap, Off. Zone, 18 ft.Assists: #88 KANE(2); #56 GUSTAFSSON(1)", "TOR ONGOAL - #44 RIELLY, Backhand, Off. Zone, 77 ft.")

```

Now I hope to get a string vector that contains only the parts
that contains the distance, that is, substring = c ("18 ft", "77 ft").

Is there a convenient way in R to do this?

Answer: 
Alternatives:

```r
regmatches(distance, gregexpr("\\b[0-9]+\\s*ft", distance, perl = TRUE))
# [[1]]
# [1] "18 ft"
# [[2]]
# [1] "77 ft"

strcapture("\\b([0-9]+\\s*ft)", distance, list(dist = ""))
#    dist
# 1 18 ft
# 2 77 ft

```

Though they're all just doing the same thing with slightly different interfaces.
Try `gsub`

```
> gsub(".*?(\\d+\\s+ft).*", "\\1", distance)
[1] "18 ft" "77 ft"

```