IHTMLTxtRange::findText Method

Searches for text in the document and positions the start and end points of the range to encompass the search string.

Syntax

HRESULT findText(      
    BSTR String,
    long count,
    long Flags,
    VARIANT_BOOL *Success
);

Parameters

String
[in] BSTR that specifies the text to find.
count
[in] long that specifies the number of characters to search from the starting point of the range. A positive integer indicates a forward search; a negative integer indicates a backward search.
Flags
[in] long that specifies one or more of the following flags to indicate the type of search:
0
Default. Match partial words. //意思是说所搜的字符串不是一个单词,一样可以搜索到(匹配一个单词的部分即可,如what中搜索wha一样可以搜索到,但如果是参数值为2,则在what中搜索不到wha)
1
Match backwards. 反向搜索
2
Match whole words only.搜索部分必须是一个单词
4
Match case. 区分大小写
131072
Match bytes. 字节对齐方式
536870912
Match diacritical marks. 变音
1073741824
Match Kashida character. 波斯语
2147483648
Match AlefHamza character.
Success
[out, retval] Pointer to a VARIANT_BOOL that returns one of the following values:
VARIANT_TRUE
The search text was found.
VARIANT_FALSE
The search text was not found.

Return Value

Returns S_OK if successful, or an error value otherwise.

Remarks

A range has two distinct states: degenerate and nondegenerate.

/*一个范围有两种截然不同的状态:退化与非退化。*/

A degenerate range is like a text editor caret (insertion point) —it does not actually select any characters. Instead, it specifies a point between two characters. The end points of a degenerate range are adjacent.

/*退化的范围就像是一个文本编辑器插入符号(插入点) - 它实际上并没有选择任何字符。相反,它指定两个字符之间的一个点。退化范围的终点是相邻的。*/

A nondegenerate range is like a text editor selection, in that it selects a certain amount of text. The end points of a nondegenerate range are not adjacent.

/*非退化范围是像一个文本编辑器的选择,因为它选择一定量的文字。非简并的范围的终点不相邻。*/

The value passed for the count parameter controls the part of the document, relative to the range, that is searched. The behavior of theIHTMLTxtRange::findText method depends on whether the state is degenerate or nondegenerate:

/*count参数传递的值控制文档范围(range)内的被搜索的部分。theIHTMLTxtRange:: findText的行为取决于状态是退化还是非退化:*/

  • If the range is degenerate, passing a large positive number causes the text to the right of the range to be searched. Passing a large negative number causes the text to the left of the range to be searched.
  • /*
  • 如果范围是退化,传递一个很大的正数,导致范围右边的文本被搜索。传递一个大的负号导致范围左边的文本被搜索。
  • */
  • If the range is nondegenerate, passing a large positive number causes the text to the right of the start of the range to be searched. Passing a large negative number causes the text to the left of the end of the range to be searched. Passing 0 causes only the text selected by the range to be searched.
  • /*
  • 如果范围是非退化,传递一个很大的正数,范围开始节点右边的文档将被搜索。传递一个大负数,范围结束节点左边的文档将被搜索.传递0仅被range选择的范围将被搜索。
  • */

This feature might not be available on non-Microsoft Win32 platforms.

/*在非32位平台上,这个特征是不可用的*/

A text range is not modified if the text specified for the IHTMLTxtRange::findText method is not found.

/*如果没有搜索到文本,range将不会被修改*/

 

藏文测试用例:

藏文单词的划界和普通英文汉字是不一样的,普通英文划分界限是空格、逗号之类的标点符号,而藏文连续的字符串中,竟然可能出现多个单词(测试用例༡༢༣༡༢༣༡༢༣༡༢༣ངལ་རྩོལ་གླ་ཕོགས་ལམ་ལུགས中的༡༢༣༡༢༣༡༢༣༡༢༣ངལ་རྩོལ་གླ་ཕོགས་ལམ་就是一个单词),要搜索一个藏文单词,必须传入正确的藏文单词,而非一个连续的藏文字符串,如果这个字符串并非一个藏文单词,那么传入2是不可能搜索到的,但可以传入0(这样就不要求一定要搜索一个完整的单词)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

北京橙溪科技

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值