Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 206970

Split string on both sides of a number

$
0
0

Let's say we have strings like these:

data
X3Y
X33U
Y231Z

I want to split data into three columns first.letter, number, last.letter, so in this case:

first.letter number last.letter
X            3      Y
X            33     U
Y            231    Z

I could extract the first and last character of the column value using substr and then use a regular expression to extract the number but this seems really cumbersome, is there a quicker way to achieve this?


Viewing all articles
Browse latest Browse all 206970

Trending Articles