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

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 209026

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>