Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,17 @@ regex --case-sensitive Hello notes.txt

Replace with a named group (rewrites the file, files without matches stay untouched)
```
regex "Name:(?<name>[A-Za-z]+)" --replace "id=${name}" names.txt
regex "Name:(?<name>[A-Za-z]+)" --replace 'id=${name}' names.txt
```

## Example Videos

[Recursive .txt search (GIF)](examples/videos/recursive-search.gif) · [MP4](examples/videos/recursive-search.mp4)

[Case-sensitive search (GIF)](examples/videos/case-sensitive.gif) · [MP4](examples/videos/case-sensitive.mp4)

[Named-group replacement (GIF)](examples/videos/named-replacement.gif) · [MP4](examples/videos/named-replacement.mp4)

## Changelog

See [CHANGELOG.md](./CHANGELOG.md).
3 changes: 3 additions & 0 deletions examples/data/names.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Name:Anna
Name:Ben
Name:Cara
3 changes: 3 additions & 0 deletions examples/data/notes.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Hello from .NET regex.
hello is lowercase and will not match this search.
Another Hello appears here.
2 changes: 2 additions & 0 deletions examples/data/recursive/readme.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Hello from the project root.
Regex keeps patterns consistent.
1 change: 1 addition & 0 deletions examples/data/recursive/src/ignored.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Hello from Markdown, excluded by the *.txt filter.
2 changes: 2 additions & 0 deletions examples/data/recursive/src/notes.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Hello from a nested folder.
hello is lowercase and will match by default.
11 changes: 11 additions & 0 deletions examples/vhs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Example recordings

The VHS tapes in this directory reproduce the examples shown in the main README. Run them from the repository root with VHS and the .NET 10 SDK installed:

```sh
vhs examples/vhs/recursive-search.tape
vhs examples/vhs/case-sensitive.tape
vhs examples/vhs/named-replacement.tape
```

Each tape writes a GIF and an MP4 to `examples/videos/`. The replacement tape starts from `examples/data/names.txt` each time and removes its temporary working copy when the recording finishes.
26 changes: 26 additions & 0 deletions examples/vhs/case-sensitive.tape
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Output examples/videos/case-sensitive.gif
Output examples/videos/case-sensitive.mp4
Require dotnet

Set Shell bash
Set FontSize 22
Set Width 1200
Set Height 480
Set Padding 24
Set Margin 16
Set MarginFill "#101522"
Set BorderRadius 12
Set WindowBar Colorful
Set Theme "Catppuccin Mocha"
Set TypingSpeed 45ms

# Build the CLI quietly and add its apphost to this recording's PATH.
Hide
Type "dotnet build regex/regex.csproj -c Release --nologo >/dev/null && alias regex=./regex/bin/Release/net10.0/regex && clear"
Enter
Sleep 1s
Show

Type "regex --case-sensitive Hello examples/data/notes.txt"
Enter
Sleep 3s
33 changes: 33 additions & 0 deletions examples/vhs/named-replacement.tape
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
Output examples/videos/named-replacement.gif
Output examples/videos/named-replacement.mp4
Require dotnet

Set Shell bash
Set FontSize 22
Set Width 1200
Set Height 520
Set Padding 24
Set Margin 16
Set MarginFill "#101522"
Set BorderRadius 12
Set WindowBar Colorful
Set Theme "Catppuccin Mocha"
Set TypingSpeed 45ms

# Build quietly, prepare a fresh writable copy, then expose the apphost.
Hide
Type "dotnet build regex/regex.csproj -c Release --nologo >/dev/null && mkdir -p examples/videos/.work && cp examples/data/names.txt examples/videos/.work/names.txt && alias regex=./regex/bin/Release/net10.0/regex && clear"
Enter
Sleep 1s
Show

Type "regex 'Name:(?<name>[A-Za-z]+)' --replace 'id=$''{name}' --verbose examples/videos/.work/names.txt"
Enter
Sleep 2s
Type "cat examples/videos/.work/names.txt"
Enter
Sleep 3s

Hide
Type "rm -f examples/videos/.work/names.txt && rmdir examples/videos/.work"
Enter
26 changes: 26 additions & 0 deletions examples/vhs/recursive-search.tape
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Output examples/videos/recursive-search.gif
Output examples/videos/recursive-search.mp4
Require dotnet

Set Shell bash
Set FontSize 22
Set Width 1200
Set Height 480
Set Padding 24
Set Margin 16
Set MarginFill "#101522"
Set BorderRadius 12
Set WindowBar Colorful
Set Theme "Catppuccin Mocha"
Set TypingSpeed 45ms

# Build the CLI quietly and add its apphost to this recording's PATH.
Hide
Type "dotnet build regex/regex.csproj -c Release --nologo >/dev/null && alias regex=./regex/bin/Release/net10.0/regex && clear"
Enter
Sleep 1s
Show

Type "regex --recursive --filter '*.txt' Hello examples/data/recursive/"
Enter
Sleep 3s
Binary file added examples/videos/case-sensitive.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/videos/case-sensitive.mp4
Binary file not shown.
Binary file added examples/videos/named-replacement.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/videos/named-replacement.mp4
Binary file not shown.
Binary file added examples/videos/recursive-search.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/videos/recursive-search.mp4
Binary file not shown.
Loading