Reg python regexp
Rhodri James
rhodri at kynesim.co.uk
Wed Mar 21 06:55:49 EDT 2018
On 21/03/18 10:44, sankarramanv at gmail.com wrote:
> Hi,
>
> I have a requirement.
>
> cmd="cat <file>|grep -c 'if [ -t 1 ]; then mesg n 2>/dev/null; fi'"
>
> I need to escape only the square brackets in above variable since its not grepping without escaping the brackets.
You need to escape the square brackets as you normally would for your
shell, with backslashes I presume. Then you need to escape the
backslashes so they aren't interpreted specially by Python, with more
backslashes.
--
Rhodri James *-* Kynesim Ltd
More information about the Python-list
mailing list