I need to exec the following command from ant, but I can't figure out how to escape the double-quotes:
tasklist /FI "IMAGENAME eq java.exe" /FI "MEMUSAGE gt 50000"
If you need to use the double quote inside the string, you can use the backslash character. Notice how the backslash in the second line is used to escape the double quote characters. And the single quote can be used without a backslash.
Double Quotes inside verbatim strings can be escaped by using 2 sequential double quotes "" to represent one double quote " in the resulting string. var str = @"""I don't think so,"" he said.
You can put a backslash character followed by a quote ( \" or \' ). This is called an escape sequence and Python will remove the backslash, and put just the quote in the string. Here is an example. The backslashes protect the quotes, but are not printed.
To allow attribute values to contain both single and double quotes, the apostrophe or single-quote character (') may be represented as "'", and the double-quote character (") as """. Show activity on this post. A double quote character ( " ) can be escaped as " , but here's the rest of the story...
Ant script is xml. So in xml, here is the rule.
For > use >
For < use <
For “ use "
For & use &
For ‘ use '
Notice! ";"
Reference:
http://www.jguru.com/faq/view.jsp?EID=721755
Ant uses XML, so you can use the normal XML entities like "
:
tasklist /FI "IMAGENAME eq java.exe" /FI "MEMUSAGE gt 50000"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With