mirror of
https://github.com/gohugoio/hugoDocs.git
synced 2025-08-04 04:58:55 -04:00
Update findRe.md
This commit is contained in:
parent
4d39137ef9
commit
513b7a43aa
@ -36,5 +36,24 @@ To limit the number of matches to one:
|
|||||||
You can write and test your regular expression using [regex101.com](https://regex101.com/). Be sure to select the Go flavor before you begin.
|
You can write and test your regular expression using [regex101.com](https://regex101.com/). Be sure to select the Go flavor before you begin.
|
||||||
{{% /note %}}
|
{{% /note %}}
|
||||||
|
|
||||||
|
## findRESubmatch
|
||||||
|
|
||||||
|
In Hugo 0.110.0 we added a variant of `findRe` that returns a slice of strings holding the text of the leftmost match of the regular expression in s and the matches, if any, of its subexpressions.
|
||||||
|
|
||||||
|
This:
|
||||||
|
|
||||||
|
```go-html-template
|
||||||
|
{{ findRESubmatch §§<a\s*href="(.+?)">(.+?)</a>§§ §§<li><a href="#foo">Foo</a></li> <li><a href="#bar">Bar</a></li>§§ | print | safeHTML }}
|
||||||
|
```
|
||||||
|
|
||||||
|
Will print:
|
||||||
|
|
||||||
|
```
|
||||||
|
[[<a href=\"#foo\">Foo</a> #foo Foo] [<a href=\"#bar\">Bar</a> #bar Bar]]
|
||||||
|
```
|
||||||
|
|
||||||
|
{{< new-in "0.110.0" >}}
|
||||||
|
|
||||||
|
|
||||||
[RE2]: https://github.com/google/re2/wiki/Syntax
|
[RE2]: https://github.com/google/re2/wiki/Syntax
|
||||||
[string literal]: https://go.dev/ref/spec#String_literals
|
[string literal]: https://go.dev/ref/spec#String_literals
|
||||||
|
Loading…
x
Reference in New Issue
Block a user