aspose file tools*
The moose likes Beginning Java and the fly likes String replacement Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "String replacement" Watch "String replacement" New topic
Author

String replacement

Mag Yeoh
Ranch Hand

Joined: Oct 08, 2006
Posts: 40





Hi need help.

need to replace the $custId and $BirthDate after retrieve the value from db. use replaceAll only can replace one time.

When return the str, it have nothing change in the str. The value i wan it replace the $custId with Customer Id and $BirthDate with Birthday Date.

Can anyone give idea. Thanks.
D. Ogranos
Ranch Hand

Joined: Feb 02, 2009
Posts: 214
replaceAll() returns the changed string, so I think you just need to assign that to your str variable again (str = str.replaceAll(...)).
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19670
    
  18

You may also want to check out java.lang.String#replace(java.lang.CharSequence, java.lang.CharSequence). This method has been added in Java 5.0 and is equal to replaceAll but with literal matching, not regular expression matching.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Mag Yeoh
Ranch Hand

Joined: Oct 08, 2006
Posts: 40
Thanks Rob Prime and D. Ogranos.....I get use to it already...

thanks very much
 
Consider Paul's rocket mass heater.
 
subject: String replacement