关于一个字符串比较的问题
最近做了一个字典的程序,可以根据英文字符串比较获得中文的字符串。
但是遇到了一种麻烦的情况
例如
"Use %s to move the box"
"使用 %s 来移动箱子。"
这种类型
传进来的英文或许是
"Use hand to move the box"
那么翻译成
"使用 手 来移动箱子"
也可能是
"Use feet to move the box"
"使用 脚 来移动箱子"
我想知道有没有什么高效的方法能够正确的匹配出
Use hand to move the box
是
Use %s to move the box
类型的字符串
我目前的做法是将字符串按单词拆开
Use hand to move the box
拆成
Use
hand
to
move
the
box
Use %s to move the box
拆成
Use
%s
to
move
the
box
然后比较除%s(索引位置为1)的所有其他位置的单词是否相同来判断
但是这样太慢了,请教达人高效的方法,不胜感激。