• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Splitting a string--delimiter is $

 
Greenhorn
Posts: 13
Netbeans IDE Netscape Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 67752
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
$ means end-of-line in Java regex's.
 
Rancher
Posts: 5076
38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Special characters need to be escaped.
 
Xander Jacob
Greenhorn
Posts: 13
Netbeans IDE Netscape Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
(6 minutes later)
Did you know that the $ has to be escaped? (Groan)

Problem = solved.
 
Eliminate 95% of the weeds in your lawn by mowing 3 inches or higher. Then plant tiny ads:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic