Splitting string into pairs with c#

前端 未结 6 526
后悔当初
后悔当初 2021-01-28 01:26

Is there a way to break a string into pairs without looking at indexes? e.g. TVBMCVTVFGTVTB would be broken into a list of strings as such:

[TV,BM,CV,TV,FG,TV,TB]

<
6条回答
  •  忘掉有多难
    2021-01-28 02:04

    If you REALLY want to avoid using indexes...

    You could use a Regex "\w\w" or "\w{2,2}" or some variation like that and MSDN - Regex.Matches method to get a MatchCollection which would contain the matches as pairs of characters. Change \w in the regex pattern to suit your needs.

提交回复
热议问题