Skip to content

Show ways to perform a "chain" of regex substitutions #4716

@schultzdavid

Description

@schultzdavid

In real-world text processing problems (including one-liners), it's not uncommon that one wants to apply several substitution regexes one after another, transforming the input text one step at a time. The docs (probably a new subsection at the bottom of language/regexes#Substitution) should expressly show a few ways to do that.

One such way could be

for lines() -> $_ is copy { 
    s/a1/a2/; 
    s/b1/B1;
    .say
}

I could write the text myself this week, but it would be good to first hear what are the "best" ways to accomplish that. (I do think that's fitting in the reference doc on regexes, because for each regex substitution operator it is of inherent interest if and how one can chain it.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsDocumentation issue (primary issue type)

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions