我想匹配兩個串彼此,而不在意三個條件:定義字符忽略同時匹配字符串C#
1-區分大小寫(都應該不區分大小寫):誰< =>誰
2-下劃線:father_of < =>的父
3缺失空間:barackobama < =>布魯克斯
因此,下面兩個字符串應當彼此匹配
誰是fatherof barack_obama < =>誰是奧巴馬的父親
我不知道從哪裏開始,我試圖讓兩個字符串的排列,考慮下劃線和缺少空格的這兩種情況下,所以它會像
Who, is, fatherof, barack_obama
who is, is fatherof, fatherof barack_obama,
whois, isfatherof, fatherofbarack_obama,
who_is, is_fatherof, fatherof_barack_obama,
who is fatherof, is fatherof barack_obama
whoisfatherof, isfatherofbarack_obama
who_is_fatherof, is_fatherof_barack_obama
who is fatherof barack_obama
whoisfatherofbarack_obama
who_is_fatherof_barack_obama
這是很好的匹配奧巴馬與barack_obama但反過來並不好,即使我能夠在兩者之間有undserscore分割字符串,我不能做到這一點與失蹤空間
您預期提出問題,而不是分配任務。 – 2012-03-24 20:24:37
@HansPassant你會得到'我該怎麼做?') – 2012-03-24 20:26:19
嗯,這是一個合理的猜測,我猜。我猜不出爲什麼我們必須猜測。 – 2012-03-24 20:30:22