title: R regex extract similar words but one has hyphen
body: <p>I have the following data frame:</p>
  
  <pre><code>species    size_description
  1          "some text Small some text"
  2          "some text small-med some text"
  3          "some text Med. some text"
  4          "some text medium some text"
  5          "some text med-large some text"
  6          "some text large some text"
  </code></pre>
  
  <p>I would like to write a regex the captures the size in the size description field, so it would look like this:</p>
  
  <pre><code>species    size_description                    newSize                            
  1          "some text Small some text"         "Small"
  2          "some text small-med some text"     "small-med"
  3          "some text Med. some text"          "Med."
  4          "some text medium some text"        "medium"
  5          "some text med-large some text"     "med-large"
  6          "some text large some text"         "large"
  </code></pre>
  
  <p>I tried to do it this way: </p>
  
  <pre><code>size_regex = paste(
                  "[Ss]{1}mall",
                  "[Mm]{1}ed\\.*i*u*m*",
                  "[Mm]{1}ed\\.*i*u*m*-*\\s*[Ll]{1}arge",       #doesnt work
                  "[Ss]{1}mall-*\\s*[Mm]{1}ed\\.*i*u*m*",       #doesnt work
                  "[Ll]{1}arge",
                  sep = "|"
                  )
  
  df$newSize = str_extract(df$size_description, age_regex)
  </code></pre>
  
  <p>BUT, it can't differentiate the ones with hyphens. For example, for species 2 it records it as "small" and not "small-med".</p>
  
  <p>How can I write a regex that will do this in R? I have preference to the stringr package, but anything will do.  </p>
  
  <p>Note the reason I leave the option for the full words in my regex is that some descriptions use the full word. For example, some may be "small-medium" while other are just "small-med".</p>