Regular expression to find and remove duplicate words

前端 未结 9 941
孤城傲影
孤城傲影 2020-11-30 09:46

Using regular expressions in C#, is there any way to find and remove duplicate words or symbols in a string containing a variety of words and symbols?

Ex.

9条回答
  •  旧时难觅i
    2020-11-30 09:54

    Some people, when confronted with a problem, think “I know, I'll use regular expressions.” Now they have two problems.

    See When not to use Regex in C# (or Java, C++ etc)

    Of course using a regex to split the string into words may be a useful first step, however String.Split() is clear and it lickly to do everything you need.

提交回复
热议问题