plugin: search and replace
This commit is contained in:
parent
4a154f16f9
commit
53b21bfd7f
4 changed files with 450 additions and 0 deletions
50
internal/plugin/searchreplace/README.md
Normal file
50
internal/plugin/searchreplace/README.md
Normal file
|
@ -0,0 +1,50 @@
|
|||
# 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
|
Loading…
Add table
Add a link
Reference in a new issue