返回介绍

Search

发布于 2019-12-03 22:55:32 字数 7194 浏览 1140 评论 0 收藏 0

A class designed to handle all sorts of text searches within a Document.

Constructors

  • new Search()

Creates a new Search object. The following search options are available:

  • needle: The string or regular expression you're looking for
  • backwards: Whether to search backwards from where cursor currently is. Defaults to false.
  • wrap: Whether to wrap the search back to the beginning when it hits the end. Defaults to false.
  • caseSensitive: Whether the search ought to be case-sensitive. Defaults to false.
  • wholeWord: Whether the search matches only on whole words. Defaults to false.
  • range: The Range to search within. Set this to null for the whole document
  • regExp: Whether the search is a regular expression or not. Defaults to false.
  • start: The starting Range or cursor position to begin the search
  • skipCurrent: Whether or not to include the current line in the search. Default to false.

Methods

Searches for options.needle. If found, this method returns the Range where the text first occurs. If options.backwards is true, the search goes backwards in the session.

sessionEditSessionRequired. The session to search with

Searches for all occurances options.needle. If found, this method returns an array of Ranges where the text first occurs. If options.backwards is true, the search goes backwards in the session.

sessionEditSessionRequired. The session to search with
  • Search.getOptions()
  • 返回值: Object

Returns an object containing all the search options.

Searches for options.needle in input, and, if found, replaces it with replacement.

inputStringRequired. The text to search in
replacementStringRequired. The replacing text

  • (String): If options.regExp is true, this function returns input with the replacement already made. Otherwise, this function just returns replacement.
    If options.needle was not found, this function returns null.
  • Chainable

Sets the search options via the options parameter.

optionsObjectRequired. An object containing all the new search properties
  • Search.setOptions()
  • Undocumented

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文