在字符串中插入空格 [英] Insert a space in a String

查看:337
本文介绍了在字符串中插入空格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好
我正在Windows基础C#应用程序上工作.如何在字符串中输入空格
例如,我现在有一个字符串A123456,现在我必须使它成为A 123456

Hi All
I am working on windows base C# application.How can I enter a space in a string
As example I have a string A123456 now I have to make it A 123456

推荐答案

string original="A123456";
string newvalue=original.Substring(0,1)+" "+original.Substring(1);


我会使用regex
I would use regex
var re = @"[A-Z]|[a-z]+)";
string value = Regex.Replace(:"A123456", re, "


0");
0");


这篇关于在字符串中插入空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆