Skip to content

Add a function like findRE that will return all sub/group matching. #10594

@razonyang

Description

@razonyang

Related topic: https://discourse.gohugo.io/t/regular-expressions-sub-matching-groups-not-supported/15368

I would like to create functions that parse and return some stuff of HTML like following.

<ul>
  <li><a href="#foo">Foo</a></li>
  <li><a href="#bar">Bar</a></li>
</ul>
pattern := `<a.*href="(.+)">(.+)</a>`

Result (something like this)

[
  [
    "<a href=\"#foo\">Foo</a>",
    "#foo"
    "Foo"
  ],
  [
    "<a href=\"#bar\">Bar</a>",
    "#bar"
    "Bar"
  ]
]

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions