如何查找子字符串并在它们之间放置空格 [英] How to find a sub string and put space in between them
本文介绍了如何查找子字符串并在它们之间放置空格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个字符串
string source = @ 当前状态:这是测试当前状态。用户体验:这是测试用户体验;
如何找到子字符串用户体验
并在子字符串<$ c $之前加一个空格c>用户体验或将用户体验
发送至下一行。
请协助
解决方案
我建议使用替换的正则表达式。
https://msdn.microsoft.com/en-us/library/az24scfc.aspx [ ^ ]
从头开始MSDN文档:
如何:使用字符串方法搜索字符串(C#编程指南) [ ^ ]
如何:搜索字符串使用正则表达式(C#编程指南) [ ^ ]
如何:修改字符串内容(C#编程指南) ) [ ^ ]
I have a string
string source = @"Current Status: this is a test current status.User Experience: This is a test user experience";
How to find the sub string "User Experience
" and put a space before the sub string "User Experience
" or put "User Experience
" to next line .
Please assist
解决方案
I recommend a Regular Expression with substitution.
https://msdn.microsoft.com/en-us/library/az24scfc.aspx[^]
Start with MSDN documentation:
How to: Search Strings Using String Methods (C# Programming Guide)[^]
How to: Search Strings Using Regular Expressions (C# Programming Guide)[^]
How to: Modify String Contents (C# Programming Guide)[^]
这篇关于如何查找子字符串并在它们之间放置空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文