Compare two strings by ignoring certain characters

前端 未结 5 821
梦毁少年i
梦毁少年i 2021-01-20 07:38

I wonder if there is an easy way to check if two strings match by excluding certain characters in the strings. See example below.

I can easily write such a method by

5条回答
  •  独厮守ぢ
    2021-01-20 07:55

    I found myself having the same requirements, the solution I used was based on the String.Compare method:

    String.Compare(str1, str2, CultureInfo.InvariantCulture, CompareOptions.IgnoreSymbols)
    

提交回复
热议问题