c# - Using regex to split string by Non Digit and Digit -


ive seen few answers similar none seem go far enough. need split string when letters change numbers , back. trick pattern variable meaning there can number of letter or number groupings.

for example

ab1000 => ab 1000 abc1500 => abc 1500 de160v1 => de 160 v 1 fgg217h5ij1 => fgg 217 h 5 ij 1 etc. 

if want split string, 1 way lookarounds:

string[] results = regex.split("fgg217h5ij1", @"(?<=\d)(?=\d)|(?<=\d)(?=\d)"); console.writeline(string.join(" ", results)); //=> "fgg 217 h 5 ij 1" 

Popular posts from this blog