Text Search¶
Search within text.
Search Module¶
Text search utilities.
This submodule provides utilities for searching within text including contains, starts_with, ends_with, find, and count operations.
Examples¶
from rite.text.search import text_contains, text_find text_contains("Hello World", "World") True text_find("Hello World", "World") 6
Modules¶
text_contains
¶
Text Contains¶
Check if text contains a substring.
Examples¶
from rite.text.search import text_contains text_contains("Hello World", "World") True
Functions¶
text_contains(text: str, substring: str) -> bool
¶
Check if text contains substring.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
Text to search in. |
required |
substring
|
str
|
Substring to search for. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if substring found. |
Examples:
Notes
Case-sensitive search.
text_count
¶
Text Count¶
Count substring occurrences in text.
Examples¶
from rite.text.search import text_count text_count("Hello Hello World", "Hello") 2
Functions¶
text_count(text: str, substring: str) -> int
¶
Count substring occurrences.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
Text to search in. |
required |
substring
|
str
|
Substring to count. |
required |
Returns:
| Type | Description |
|---|---|
int
|
Number of non-overlapping occurrences. |
Examples:
Notes
Uses str.count() which counts non-overlapping occurrences.
text_ends_with
¶
Text Ends With¶
Check if text ends with suffix.
Examples¶
from rite.text.search import text_ends_with text_ends_with("Hello World", "World") True
Functions¶
text_ends_with(text: str, suffix: str) -> bool
¶
Check if text ends with suffix.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
Text to check. |
required |
suffix
|
str
|
Suffix to search for. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if text ends with suffix. |
Examples:
Notes
Uses str.endswith() method.
text_find
¶
Text Find¶
Find substring position in text.
Examples¶
from rite.text.search import text_find text_find("Hello World", "World") 6
Functions¶
text_find(text: str, substring: str) -> int
¶
Find substring position in text.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
Text to search in. |
required |
substring
|
str
|
Substring to find. |
required |
Returns:
| Type | Description |
|---|---|
int
|
Index of substring or -1 if not found. |
Examples:
Notes
Uses str.find() method. Returns -1 if not found.
text_starts_with
¶
Text Starts With¶
Check if text starts with prefix.
Examples¶
from rite.text.search import text_starts_with text_starts_with("Hello World", "Hello") True
Functions¶
text_starts_with(text: str, prefix: str) -> bool
¶
Check if text starts with prefix.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
Text to check. |
required |
prefix
|
str
|
Prefix to search for. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if text starts with prefix. |
Examples:
Notes
Uses str.startswith() method.
options: show_root_heading: true show_source: false heading_level: 2