IHTMLTxtRange::findText Method

来源:互联网 发布:php过滤频繁ip请求 编辑:程序博客网 时间:2024/05/02 21:46

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(这样就不要求一定要搜索一个完整的单词)