regex -- split one column into multiple columns with no explicit delimiters in R
<p>I have a column in my data set called "Market.Pair" that contains information about departure and destination points of some flights. For example:</p>

<pre><code>input &lt;- data.frame(Market.Pair = c("US to/from CA", "HOU to/from DFW/DAL", "EWR/JFK to/from LAX/SFO", "US-NYC to/from FR-PAR", "US to/from Asia"))
input
</code></pre>

<p>All two letter words represent countries(ex. US, CA).
All three letter words(or multiple three letter words separated by "/") represent airports(ex. HOU, DFW/DAL).
All words in the form of XX-XXX represent cities (ex. US-NYC).
Other words represent regions, such as Asia, or Europe.</p>

<p>I would like to split this column into multiple columns:</p>

<pre><code>output&lt;- data.frame(Air.1 = c("HOU", "EWR/JFK", "", "", ""), Air.2 = c("DFW/DAL", "LAX/SFO", "", "", ""), City.1 = c("","","US-NYC", "", ""), City.2 = c("","","FR-PAR", "", ""), Country.1 = c("","","","US", "US"), Coutry.2 = c("","","","CA", ""), Region.1 = c("","","", "", "Asia"), Region.2 = c("","","", "", ""))
output
</code></pre>

<p>I am new to regex, so any help will be much appreciated!</p>