Guf*_*ffa 19
让我们从代码审查的答案中借用一个实现.这会每n个字符插入一个换行符:
public static string SpliceText(string text, int lineLength) {
return Regex.Replace(text, "(.{" + lineLength + "})", "$1" + Environment.NewLine);
}
Run Code Online (Sandbox Code Playgroud)
编辑:
返回一个字符串数组:
public static string[] SpliceText(string text, int lineLength) {
return Regex.Matches(text, ".{1," + lineLength + "}").Cast<Match>().Select(m => m.Value).ToArray();
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
15193 次 |
| 最近记录: |