Skip to content

Can I split long regex into multiple lines? #8

Open

Description

@dausruddin

Since there is a lot to type for each replacement, I am combining many regex into one. But this resulting in a very long line. Can I somehow split a regex into multiple lines in this module? Something like:

filter {
    search_pattern "(todelete1\
|todelete2\
|todelete3)"
    replacement ""
    content_type html
}

Thank you.

Activity

  1. skyzh commented on Oct 4, 2021

    @skyzh
    Member

    I don't think caddy's config parser would support it. cc @htfy96 could you please take a look?

  2. htfy96 commented on Oct 12, 2021

    @htfy96
    Contributor

    Sorry for the late response. I'll take a look into this after work today

  3. htfy96 commented on Oct 15, 2021

    @htfy96
    Contributor

    I think Caddy by default already supports escaping line end with \:

    config

    {
        debug
        auto_https off
        order filter after encode
    }
    http://localhost:2015 {
        filter {
            content_type .*
            search_pattern "aaa\
    |bbb\
    |ccc"
            replacement "replaced"
        }
    
        respond "ccc"
    }
    
    $ curl http://localhost:2015
    replaced
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions