🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.jbuilder.java.api
3 messages
3 total messages Started by RaynorPao Mon, 24 Mar 2003 06:02
StringReplace function
#641
Author: RaynorPao
Date: Mon, 24 Mar 2003 06:02
14 lines
1345 bytes
Hi all:

In BCB/Delphi, there is a function "StringReplace" can be used.
For example, I write a code as below(BCB):

AnsiString sz="a_b_c_d_e_f";
sz=StringReplace(sz, "_", "", TReplaceFlags()<<rfReplaceAll);

It can change the AnsiString sz from "a_b_c_d_e_f" to "abcdef".
So...My question is....Is there an API like "StringReplace" in Java?
Or there is another simple way can solve this problem?

Thanks.
RaynorPao.
Re: StringReplace function
#642
Author: John McGrath TeamB
Date: Mon, 24 Mar 2003 06:34
21 lines
1590 bytes
On Mon, 24 Mar 2003 14:02:24 +0800, RaynorPao wrote:

> Is there an API like "StringReplace" in Java?

See the replaceAll() and replaceFirst() methods in the String class.  
These work with regular expressions, so they are quite a bit more 
powerful than the method you describe.

However, these methods were introduced in Java 1.4.  Previous Java 
versions (and 1.4 as well) have a replace() method that will replace 
each occurrence of one character with another, but that does not seem 
to be what you need.

-- 
Regards,

John McGrath [TeamB]

---------------------------------------------------
Before sending me e-mail, please read:
    http://www.JPMcGrath.net/newsgroups/e-mail.html
Re: StringReplace function
#643
Author: RaynorPao
Date: Mon, 24 Mar 2003 06:54
31 lines
1965 bytes
Hi John:

Thanks for your information very much.
I will try it later.

Thanks.
RaynorPao.

"John McGrath [TeamB]" <ng-b@JPMcGrath.net> ���g��l��
news:MPG.18e87115f6dbabd198beee@newsgroups.borland.com...
> On Mon, 24 Mar 2003 14:02:24 +0800, RaynorPao wrote:
>
> > Is there an API like "StringReplace" in Java?
>
> See the replaceAll() and replaceFirst() methods in the String class.
> These work with regular expressions, so they are quite a bit more
> powerful than the method you describe.
>
> However, these methods were introduced in Java 1.4.  Previous Java
> versions (and 1.4 as well) have a replace() method that will replace
> each occurrence of one character with another, but that does not seem
> to be what you need.
>
> --
> Regards,
>
> John McGrath [TeamB]
>
> ---------------------------------------------------
> Before sending me e-mail, please read:
>     http://www.JPMcGrath.net/newsgroups/e-mail.html
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads