Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / July 2006

Tip: Looking for answers? Try searching our database.

replace multiple occurances of string with a single string

Thread view: 
ranumehta79@gmail.com - 31 Jul 2006 00:33 GMT
Hi,

I want to replace mulitple occurances of a string one after the another
with a single string

for eg .

input   : a hello b world c java abcabcabc
output:  a hello b world c java def

I mean multiple occurances of pattern 'abc' with a single string 'def'.

how can do this with JAVA regular expressions ?

I tried replaceAll method in string class, but I dont know how to
format regular expression.

thanks
Ranu
Flávio Barata - 31 Jul 2006 12:57 GMT
Hi,

Try this piece of code:

"a hello b world c java abcabcabc".replaceAll("(abc)+", "def")

flavio

> Hi,
>
[quoted text clipped - 15 lines]
> thanks
> Ranu


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.