Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

help regarding escape character

 
Venu Chakravorty
Ranch Hand
Posts: 46
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
i get a compile time error upon compiling:



perhaps because "\d" is not an escape character, where as in the next code:



"/d" gets printed when i invoke - java A "\d".
in the later case doesn't the String "\d" get assigned to "args[0]"? or maybe i am getting no error because i am trying to assign a value at runtime?

regards, venu
 
Sebastian Janisch
Ranch Hand
Posts: 1183
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The values passed to the program are escaped by the JVM ...
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24204
34
Chrome Eclipse IDE Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The only thing that's relevant here is that to write an actual '\' character inside a String in Java source code, you must double it:

args[0] = "\\d";

The same goes for character constants:

char c = '\\';

There's no "escaping" of characters read from the command line or from files; a \ is just an ordinary character at runtime. Escaping is just used to turn off the special meaning of the \ character in source code.

 
Venu Chakravorty
Ranch Hand
Posts: 46
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic