追加和prepending在字符串'#'仅使用正则表达式 [英] Appending and Prepending '#' in an string using only Regex
本文介绍了追加和prepending在字符串'#'仅使用正则表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是新来的正则表达式和最近面临这个问题。
追加和prepending仅使用正则表达式的字符串'#'
在此假设我们有字符串,如你好,我的名字是#First名称#@EducationDetail @
现在我不得不追加和prePEND #
在此只使用常规EX pression因此,它将成为
#Hello我的名字是#First名称#@EducationDetail @#
感谢
解决方案
VAR RES = Regex.Replace(输入,@^(*)$,#$ 1号);
I am new to regex and recently faced this problem
Appending and Prepending '#' in an string using only Regex
In this suppose we have string such as Hello my name is #First Name# @EducationDetail@
Now I have to append and prepend #
in this using only regular expression so it will become
#Hello my name is #First Name# @EducationDetail@#
Thanks
解决方案
var res = Regex.Replace(input, @"^(.*)$", "#$1#");
这篇关于追加和prepending在字符串'#'仅使用正则表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文