WordPattern class

WordPattern class

Represents a word pattern for the wildcard search.

A pattern is a sequence of values, each of them either a character or a wildcard. A wildcard carries the flag that puts it above System.Char.MaxValue, together with the least and the greatest number of characters it stands for, therefore a character of the pattern is anything that fits into a UTF-16 code unit.

The WordPattern type exposes the following members:

Constructors

Constructor Description
init Initializes a new instance of the WordPattern class.

Methods

Method Description
append_character Appends a character to the word pattern.
append_one_character_wildcard Appends a wildcard for exactly one character to the word pattern.
append_one_or_more_characters_wildcard Appends a wildcard that matches one or more characters to the word pattern.
append_string Appends a string to the word pattern.
append_wildcard Appends a wildcard to the word pattern.
append_zero_or_more_characters_wildcard Appends a wildcard that matches zero to 255 characters to the word pattern.
append_zero_or_one_character_wildcard Appends a zero-or-one character wildcard to the word pattern.
to_string Returns a string that represents the current WordPattern.

Example

from groupdocs.search import SearchQuery
from groupdocs.search.common import WordPattern

# Create a pattern that matches words like "merry" or "marry"
pattern = WordPattern()
pattern.append_string("m")
pattern.append_one_character_wildcard()
pattern.append_string("rry")
query = SearchQuery.create_word_pattern_query(pattern)
result = index.search(query)

# Create a pattern that matches words like "cardiff", "cardinal", "cardio", "cards"
pattern2 = WordPattern()
pattern2.append_string("card")
pattern2.append_wildcard(1, 6)  # matches between 1 and 6 characters
query2 = SearchQuery.create_word_pattern_query(pattern2)
result2 = index.search(query2)

Guides

Task guides that use WordPattern:

See Also