• Post Reply Bookmark Topic Watch Topic
  • New Topic

Splitting a string--delimiter is $  RSS feed

 
Xander Jacob
Greenhorn
Posts: 13
Java Netbeans IDE Netscape
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm insane, but that's beside the point.

The point is that a String's split method returns a one-element array when I use "$" as the delimiter.
1: I am absolutely sure the source (regex) has $'s in it.
2: This method works beautifully for every delimiter but $.
Is it a special character? I haven't found any escape codes for it.

Here's a snippet of the code, asssuming dd is a String.




I have a piece of code here that proves the existence of $:





Netbeans 8.0.1, Java 1.8.

...and yes, I have tried restarting Netbeans.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66306
152
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
$ means end-of-line in Java regex's.
 
Norm Radder
Rancher
Posts: 2240
28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Special characters need to be escaped.
 
Xander Jacob
Greenhorn
Posts: 13
Java Netbeans IDE Netscape
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
(6 minutes later)
Did you know that the $ has to be escaped? (Groan)

Problem = solved.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!