butterrobot/internal/plugin/searchreplace/README.md
Felipe M. a9b4ad52cb
All checks were successful
ci/woodpecker/push/ci Pipeline was successful
ci/woodpecker/tag/release Pipeline was successful
plugin: search and replace
2025-05-09 14:01:00 +02:00

50 lines
No EOL
1.4 KiB
Markdown

# 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 term
- `flags` (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 case
- `n` - Treat search pattern as a regular expression (advanced users)
### Examples
1. Basic replacement (replaces first occurrence):
```
s/hello/hi/
```
2. Global replacement (replaces all occurrences):
```
s/hello/hi/g
```
3. Case-insensitive replacement:
```
s/Hello/hi/i
```
4. 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