c# - 如何删除字符串的可变部分? [英] c# - How do i remove a variable part of a string?
本文介绍了c# - 如何删除字符串的可变部分?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想删除部分字符串.它必须匹配/*/cms/"(不带引号).* 将是一个通配符,等于除/键之外的任何内容.字符串可能有多个匹配项要删除.
I would like to remove part of a string. It would have to match "/*/cms/" (without the quotes). * would be a wildcard equaling anything except a / key. The string could have more than one match to be removed.
这必须在 C# 中完成.我认为这可以用正则表达式来完成?但我不确定.
This would have to be done in c#. I think this can be done with a regex? But I'm not sure.
推荐答案
要匹配的正则表达式是/[^/]*/cms/
,这样使用:new Regex("/[^/]*/cms/").Replace(yourString, "")
The regex to match that is /[^/]*/cms/
, used like this: new Regex("/[^/]*/cms/").Replace(yourString, "")
这篇关于c# - 如何删除字符串的可变部分?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文