Представьте несколько команд в виде строки вместе с помощью & & команда:
./run.sh && tail -f log.txt
или
kill -9 1111 && ./start.sh
you first would need to format string and then use regex. It really doesn't worth it to put everything into a single line. Escaping is done by doubling the curly braces:
>>> pat= '^(w{{3}}\.)?([0-9A-Za-z-]+\.){{1}}{domainName}$'.format(domainName = 'delivery.com')
>>> pat
'^(w{3}\\.)?([0-9A-Za-z-]+\\.){1}delivery.com$'
>>> re.match(pat, str1)
Also, re.match
is matching at the beginning of the string, you don't have to put ^
if you use re.match
, you need ^
if you're using re.search
, however.
Please note, that {1}
in regex is rather redundant.
Per the documentation, if you need a literal {
or }
to survive the formatting opertation, use {{
and }}
in the original string.
'^(w{{3}}\.)?([0-9A-Za-z-]+\.){{1}}{domainName}$'.format(domainName = 'delivery.com')