SPLITTING STRING WITH DELIMETER

e.g. with Regex:
grafik


 strText
 "123456789"
 strPattern
 "\d{3}"
 new Regex(strPattern).Replace(strText,function (m) m.Groups(0).Value & "-").TrimEnd({"-"c})
 "123-456-789"

And also:
grafik

as another of other options with LINQ along with its typically Overhead at Syntax:
grafik

String.Join("",strText.Select(Function (x,i) If((i+1) Mod 3 = 0, x & "-", x)).toArray).TrimEnd("-"c)
 "123-456"
1 Like