c# - Split alphanumeric string to array containing the alphabet and numeric characters separately -
i'm looking find way split alphanumeric string like
"foo123bar"
into array contains so
array[0] = "foo" array[1] = "123" array[2] = "bar"
i'm not sure best way achieve is, because strings i'm comparing follow no specific pattern far first, alphabet or numbers, or how many times each appear. example of following:
"foo123bar" "123bar" "foobar123" "foo123bar2"
i'm trying find out if there more efficient way of doing other splitting string character character , checking see if it's numeric.
string input = "foo123bar"; var array = regex.matches(input, @"\d+|\d+") .cast<match>() .select(m => m.value) .toarray();
Comments
Post a Comment