.. | ||
README.md | ||
searchreplace.go | ||
searchreplace_test.go |
Search and Replace Plugin
This plugin allows users to perform search and replace operations on messages by replying to a message with a search/replace command.
Usage
To use the plugin, reply to any message with a command in the following format:
s/search/replace/[flags]
Where:
search
is the text you want to find (case-sensitive by default)replace
is the text you want to substitute in place of the search termflags
(optional) control the behavior of the replacement
Supported Flags
g
- Global: Replace all occurrences of the search term (without this flag, only the first occurrence is replaced)i
- Case insensitive: Match regardless of casen
- Treat search pattern as a regular expression (advanced users)
Examples
-
Basic replacement (replaces first occurrence):
s/hello/hi/
-
Global replacement (replaces all occurrences):
s/hello/hi/g
-
Case-insensitive replacement:
s/Hello/hi/i
-
Combined flags (global and case-insensitive):
s/hello/hi/gi
Limitations
- The plugin can only access the text content of the original message
- Regular expression support is available with the
n
flag, but should be used carefully as invalid regex patterns will cause errors - The plugin does not modify the original message; it creates a new message with the replaced text