函数
GLibstr_match_string
自 2.40 开始
[−]
声明 [源]
gboolean
g_str_match_string (
const gchar* search_term,
const gchar* potential_hit,
gboolean accept_alternates
)
[−]
描述 [源]
检查对 search_term
执行的搜索是否应匹配 potential_hit
。
此函数分别对 search_term
和 potential_hit
调用 g_str_tokenize_and_fold()
。对于 search_term
永远不考虑 ASCII 交替,但根据 accept_alternates
的值,将考虑 potential_hit
的 ASCII 交替。
当 search_term
中的每个折叠令牌都是 potential_hit
中折叠令牌的前缀时,发生匹配。
根据您执行的搜索方式,通常在对语料库中的每个字符串调用 g_str_tokenize_and_fold()
并在返回的折叠令牌上建立索引后,再对搜索词调用 g_str_tokenize_and_fold()
并在该索引中执行查找会更快速。
例如,搜索‘fred’会匹配潜在的命中词‘Smith, Fred’和‘Frédéric’。搜索‘Fréd’会匹配‘Frédéric’,但不会匹配‘Frederic’(由于重音匹配的单向性质)。搜索‘fo’会匹配‘Foo’和‘Bar Foo Baz’,但不会匹配‘SFO’(因为没有单词以前缀‘fo’开头)。
自 2.40 开始可用
[−]
参数
search_term
-
类型:
const gchar*
用户搜索词。
数据由函数的调用者拥有。 该值是一个以 NUL 结尾的 UTF-8 字符串。 potential_hit
-
类型:
const gchar*
可能是命中词的文本。
数据由函数的调用者拥有。 该值是一个以 NUL 结尾的 UTF-8 字符串。 accept_alternates
-
类型:
gboolean
如果为真,将接受 ASCII 交替。