From c88350336e1b5adfc2bad3c696babb6aa9430799 Mon Sep 17 00:00:00 2001 From: Thor Whalen <1906276+thorwhalen@users.noreply.github.com> Date: Sat, 8 Feb 2025 20:53:40 +0100 Subject: [PATCH] Update README.md --- README.md | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 4973394..e293e0d 100644 --- a/README.md +++ b/README.md @@ -14,9 +14,38 @@ That is, modules are all self contained (so can easily be copy-paste-vendored Further, many functions will contain their own imports: Those functions can even be copy-paste-vendored by just copying the function body. - # Examples of utils +## Find and replace + +`FindReplaceTool` is a general-purpose find-and-replace tool that can treat the input text as a continuous sequence of characters, +even if operations such as viewing context are performed line by line. + +The basic usage is + +```python +FindReplaceTool("apple banana apple").find_and_print_matches(r'apple') +``` + + Match 0 (around line 1): + apple banana apple + ^^^^^ + ---------------------------------------- + Match 1 (around line 1): + apple banana apple + ^^^^^ + ---------------------------------------- + +```python +FindReplaceTool("apple banana apple").find_and_replace(r'apple', "orange") +``` + + 'orange banana orange' + +[See more examples in documentation](https://i2mint.github.io/lkj/module_docs/lkj/strings.html#lkj.strings.FindReplaceTool) + +[See here a example of how I used this to edit my CI yamls](https://github.com/i2mint/lkj/discussions/4#discussioncomment-12104547) + ## loggers ### clog