Skip to content

Add structural regular expression support #2

@shawnw

Description

@shawnw

To quote from Rob Pike's paper

First, as discussed earlier, the text passed to the actions would be defined, rather than merely selected, by the patterns

Next, the expressions would define how the input is parsed. Instead of using the restrictive idea of afield separator, the iterations implied by closures in the expression can demarcate fields. [...] We can modify this idea to define the ‘fields’ in awk, so $1 defines the first element of the closure (the first line), $2 the second, and so on. More interestingly, the closures could generate indices for arrays, so the fields would be called, say, input[1] and so on, perhaps with the unadorned identifier input holding the original intact string. This has the advantage that nested closures can generate multi-dimensional arrays, which is notationally clean.

Essentially, instead of splitting a file into records and processing them one at a time, treat it as a whole, applying rules to every match of a RE found.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions