I have a kinda simple problem, but I want to solve it in the best way possible. Basically, I have a string in this kind of format: <some letters><some numbers>
, i.e. q1
or qwe12
. What I want to do is get two strings from that (then I can convert the number part to an integer, or not, whatever). The first one being the "string part" of the given string, so i.e. qwe
and the second one would be the "number part", so 12
. And there won't be a situation where the numbers and letters are being mixed up, like qw1e2
.
Of course, I know, that I can use a StringBuilder
and then go with a for
loop and check every character if it is a digit or a letter. Easy. But I think it is not a really clear solution, so I am asking you is there a way, a built-in method or something like this, to do this in 1-3 lines? Or just without using a loop?