Results 1 to 2 of 2
- 09-15-2011, 10:40 AM #1
Member
- Join Date
- Sep 2011
- Posts
- 1
- Rep Power
- 0
how to copy a string and replace all the spaces with tabs
i attempted this program as follows but am being asked that i do not copy a string. can anyone help
Java Code:public class stringCopy { public stringCopy() { // TODO Auto-generated constructor stub } public String CopyString(String s){ String grt= new String(); return s.replaceAll("\\s+", "\t"); } public String subString(String s,String sub){ String str[]=new String[10]; if ((s!=null)&&(sub!=null)){ s.replaceAll(sub, ""); for (int i = 0; i < str.length; i++) { str[i]= s.replaceAll(sub, ""); } } return s.replaceAll(sub, ""); } /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub stringCopy str = new stringCopy(); System.out.println(str.CopyString("Strings are good to work with")); System.out.println(str.subString("Strings are good to work with","work")); } }Last edited by Norm; 09-15-2011 at 01:51 PM. Reason: added code tags
- 09-15-2011, 01:51 PM #2
Similar Threads
-
String.replace ?!
By HearT.Hunt3r in forum New To JavaReplies: 4Last Post: 08-22-2011, 03:04 AM -
Replace a cell with Spaces
By Shyamz1 in forum New To JavaReplies: 11Last Post: 11-07-2010, 02:37 PM -
How to display a String that contains more than one white spaces
By thachun in forum JavaServer Pages (JSP) and JSTLReplies: 2Last Post: 09-27-2009, 09:16 AM -
Checking if string contains only tabs/spaces/newlines/carriage returns
By Singing Boyo in forum New To JavaReplies: 3Last Post: 08-20-2009, 03:57 PM -
Replace String
By Raeghin in forum New To JavaReplies: 1Last Post: 07-28-2009, 03:58 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks