Regex in bash

werm.w get_for_branch /werm/werm-docker-srv/wordpress-0/environments/werm/containers/fe/db-mysql production
sed 's/environments\/[a-z]\+/production/g' <<< $1

that escaping of the plus sign annoys me

https://www.pcre.org/

The PCRE library is a set of functions that implement regular expression pattern matching using the same syntax and semantics as PerlĀ 5

pcre (Perl Compatible Regular Expressions)
perl -p -e 's/environments\/[a-z]+/production/g' <<< $1

alot cleaner

Leave a Reply

Your email address will not be published.