Regular expression: matching multiple words
<p>I am using regular expressions in R to extract strings from a variable. The variable contains distinct values that look like:</p>

<p>MEDIUM /REGULAR INSEAM</p>

<p>XX LARGE /SHORT INSEAM</p>

<p>SMALL /32" INSM</p>

<p>X LARGE /30" INSM</p>

<p>I have to capture two things: the value before the <code>/</code>  as a whole(SMALL,XX LARGE) and the string(alphabetic or numeric) after it. I dont want the <code>" INSM</code> or the <code>INSEAM</code> part.</p>

<p>The regular expression for first two I am using is <code>([A-Z]\w+) \/([A-Z]\w+) INSEAM</code> and for the last two I am using <code>([A-Z]\w+) \/([0-9][0-9])[" INSM]</code>.
The part <code>([A-Z]\w+)</code> only captures one word, so it works fine for MEDIUM and SMALL, but fails for X LARGE, XX LARGE etc. Is there a way I can modify it to capture two occurances of word before the <code>/</code> character? Or is there a better way to do it?</p>

<p>Thanks in advance!</p>