Skip to content

Commit 975d9a8

Browse files
authored
doc: add regexp template example (#100)
1 parent 8a4bf35 commit 975d9a8

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,8 @@ your regular expressions.
506506
> If you want your regular expression itself to be case insensitive, consider
507507
> setting the case-insensitive flag `(?i)` at the start of your expression.
508508
509+
When using the [YAML Sequence syntax](#syntax) as the argument, a [regexp template](https://pkg.go.dev/regexp#Regexp.Expand) can be supplied optionally as a single string-to-string mapping in the sequence. Refer to the `Bernoulli` example below for a demonstration of pattern group reordering. Note that a templated rewrite will be returned wholly as the sorting key.
510+
509511
[RE2 regular expressions]: https://github.com/google/re2/wiki/Syntax
510512
[lexicographically]: https://en.wikipedia.org/wiki/Lexicographic_order
511513

@@ -607,7 +609,7 @@ Data Size B 250K
607609
```
608610

609611
```diff
610-
+keep-sorted start skip_lines=1 by_regex=['\w+ (\w+)', '(\w+) \w+']
612+
+keep-sorted start skip_lines=1 by_regex=['^(?<first_name>\w+) (?<last_name>\w+)$': '${last_name} ${first_name}']
611613

612614
Daniel Bernoulli
613615
Jacob Bernoulli

0 commit comments

Comments
 (0)