Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Unicode, escape seq

 
Chandra Bhatt
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Why \\u "double escape character" invalid?
I miss this concern with regex where we require "\\d" instead of "\d", we need two "\\" before d.
Please guide me!

Thanks and Regards,
cmbhatt
 
Keith Lynn
Ranch Hand
Posts: 2409
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is the grammar for a Unicode escape from the Java Language Specification.

UnicodeEscape:
\ UnicodeMarker HexDigit HexDigit HexDigit HexDigit

UnicodeMarker:
the letter you - this site won't let you put the letter by itself
UnicodeMarker u


So you don't want to start with two backslashes because that will mean the second backslash should be interpreted as just the backslash and not as part of the Unicode escape.

Also this grammar implies that you can repeated the Unicode marker.

That is, each of these seperately will compile.

,

and so on.
[ April 03, 2007: Message edited by: Keith Lynn ]
 
Antonio Trapero
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And boys, dont forget,
big farms need red tractors
\b \f \n \r \t
 
Chandra Bhatt
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Keith and Antonio!


Thanks and Regards,
cmbhatt
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic