How to extract data between two whitespaces in R using gsub?

r
hackathon
data_wrangling

#1

Hello,

How can I use gsub function to extract data between two whitespaces in R?
I can extract data before first whitespce using ->

gsub( " .*$", “”, columnName )

How to modify it to extract data between two particular whitespaces?
Thanks.


#2

I have used this in 2 steps :

 K<-gsub('Year\\(s\\)','\\-',columnName)
 gsub('Month\\(s\\)','\\',K)

and result is in form of this “8 - 0”.Now how to handle this any suggestion