About String

Hi,String s1 = "123";String s2 = "abcdefg abcfrjh abc";How can I change in s2 where I have "abc" to "123"?the result that I whant is:s2 = "123defg 123frjh 123";ThanksYael
[226 byte] By [yael800a] at [2007-11-26 13:01:00]
# 1

> Hi,

> String s1 = "123";

> String s2 = "abcdefg abcfrjh abc";

> How can I change in s2 where I have "abc" to "123"?

> the result that I whant is:

> s2 = "123defg 123frjh 123";

>

> Thanks

> Yael

Have a look at String's replaceAll(...) method:

http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html

prometheuzza at 2007-7-7 17:01:55 > top of Java-index,Java Essentials,Java Programming...
# 2
Am I need to use with this?str.replaceAll("abc", "123");
yael800a at 2007-7-7 17:01:55 > top of Java-index,Java Essentials,Java Programming...
# 3
> Am I need to use with this?> str.replaceAll("abc", "123");Have you tried it? Have you read the Javadoc for replaceAll() and for Pattern?
sabre150a at 2007-7-7 17:01:55 > top of Java-index,Java Essentials,Java Programming...
# 4
Yes, It is work.
yael800a at 2007-7-7 17:01:55 > top of Java-index,Java Essentials,Java Programming...
# 5
> Yes, It is work.But have you read the Javadoc for replaceAll() and for Pattern because it not always as simeple as your current usage would suggest.
sabre150a at 2007-7-7 17:01:55 > top of Java-index,Java Essentials,Java Programming...