Regular Expressions 101

Community Patterns

Remove specified entry from etcd configuration

0

Regular Expression
Python

r"
((?:^ETCD_INITIAL_CLUSTER=)(?:[a-z0-9-.]{10,}=https:\/\/[0-9]+(?:\.[0-9]+){3}:2380,?){0,2})(,?app-failedhost-eeeeeeeeee.node.consul=https:\/\/[0-9]+(?:[.][0-9]+){3}:2380,?)((?:,?[a-z0-9-.]{15,}=https:\/\/[0-9]+(?:\.[0-9]+){3}:2380,?){0,2})
"
gm

Description

Given a hostname, which in the example is app-failedhost-eeeeeeeeee.node.consul, and a ETCD_INITIAL_CLUSTER= line with three hosts listed, print out the line with the given host removed

Examples (3) with the host in first, second, or last position

Submitted by stephenwb - 3 years ago