i know use escape characters \n next line , \t tab. today while working on few string came across \\$. had print "nike$" print had modify string "nike\\$". want know exact difference between \ , \\.
inside string literal, \ escape: next character follows tells do, in \n example newline.
this means can't put \ in string on own, since it's half of escape sequence. instead, have \ in string, use \\.
i had print
"nike$"print had modify string"nike\\$"
"nike\\$" result in string outputs (for instance, via system.out.println) nike\$, not nike$.
your use of \\$ suggests me feeding regular expression pattern something, e.g.:
p = pattern.compile("nike\\$"); in situation, have 2 levels of escaping going on: string literal, , regular expression. have literal $ in regular expression, has escaped \ because otherwise it's end-of-input assertion. \$ regular expression parser when using string literal, have escape backslash in literal have backslash in string regular expression engine see, \\$.
Comments
Post a Comment