问题描述
我如何可以通过多种模式给regex.replace()模式的参数?
How can i pass multiple patterns to the regex.replace() pattern parameter?
在PHP中,你干脆放弃包含它们的阵列。是否有某种相同的选项在C#?
In PHP you just give up the array containing them. Is there some kind of same option in C#?
我遍历了一些用户名和其中的一些用户名是由html标签包围。 HTML标签都不尽相同。但我知道他们是哪个。
I'm looping through some usernames and some of those usernames are surrounded by html tags. The html tags are not all the same. But i do know which ones they are.
所以,如果我可以通过多种方式来查找在regex.replace()模式参数,将是很好的。否则我将不得不为每个HTML标记的独立模式,运行regex.replace()函数。
So if i can pass multiple patterns to look for in the regex.replace() pattern parameter, would be nice. Or i'll have to make for each html tag a separate pattern and run the regex.replace() function.
希望我清楚我想要完成!
Hope i'm clear about what i'm trying to accomplish!
在此先感谢!
@Alan摩尔,
底线,去除所有的HTML标记出一串,就是我想要做的。
Bottom line, removing all html tags out of a string, is what i'm trying to do.
[/编辑]
推荐答案
所以,你有一个字符串列表,每一个全部由任选包含在HTML标签的用户名呢?它不应该的问题他们是哪些标记;只是删除任何的看起来的类似这样的标记:
So you have a list of strings, each consisting entirely of a user name optionally enclosed in HTML tags? It shouldn't matter which tags they are; just remove anything that looks like a tag:
name = Regex.Replace(name, @"</?\w+[^<>]*>", String.Empty);
这篇关于在regex.replace C#多模式()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!