Java Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesJava Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old April 7th, 2003, 02:13 AM
glkrr glkrr is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Location: malaysia
Posts: 13 glkrr User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via Yahoo to glkrr
appendandreplace

hi everybody..

How to appendReplace multiple values in java.util.regex.I did single value in java.util.regex. plz send one example for multiple value purpose
THis is single appendReplace value code

import java.util.regex.*;

public class AllData {


public static void main(String args[])throws Exception
{




String lower="<a href";
Pattern p = Pattern.compile(lower);
String strlow="this is to test <a href=http://www.k7mail.com>k7mail.com</a> <A HREF=http://www.k2mail.com> k2mail.com </a> ";

String upper="<A HREF";
String fill=" ";
fill=strlow.replaceAll(upper,lower);

StringBuffer buf = new StringBuffer(fill);

Matcher m = p.matcher(buf.toString());

String kk=buf.toString();
StringBuffer sb = new StringBuffer(kk);
while(m.find(0))
{
m.appendReplacement(sb,"target=_blank href");
}
m.appendTail(sb);
System.out.println("The output is "+sb.toString());



}

}

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesJava Help > appendandreplace


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway