Results 1 to 6 of 6

Thread: [RESOLVED] How Can I replace Enter chars in a string

  1. #1

    Thread Starter
    PowerPoster Nitesh's Avatar
    Join Date
    Mar 2007
    Location
    Death Valley
    Posts
    2,556

    Resolved [RESOLVED] How Can I replace Enter chars in a string

    Hi Guys,

    Please show me how to replace enter characters in a string

  2. #2
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    Re: How Can I replace Enter chars in a string

    String.replace
    "I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
    My Blog

  3. #3

    Thread Starter
    PowerPoster Nitesh's Avatar
    Join Date
    Mar 2007
    Location
    Death Valley
    Posts
    2,556

    Re: How Can I replace Enter chars in a string

    Hi ComputerJy,

    Thanks. But I need to know what the enter chracter is.Will it be Chr(10) for example.

  4. #4
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    Re: How Can I replace Enter chars in a string

    If its a typical text file then you can use string.replaceAll on the carriage return + line feed combination (use regex). try "\\n" first as the pattern.. if that doesn't work try "\\r" or "\\r\\n"

  5. #5
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    Re: How Can I replace Enter chars in a string

    Code:
    str.replace(System.getProperty("line.separator"), "NewLine");
    Where str is a String instance, notice that the line.separator property differs between OSs (\n in unix & \r\n in windows).
    You can also use the \n character directly
    "I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
    My Blog

  6. #6

    Thread Starter
    PowerPoster Nitesh's Avatar
    Join Date
    Mar 2007
    Location
    Death Valley
    Posts
    2,556

    Re: How Can I replace Enter chars in a string

    thanks a lot guys. That is exactly what I needed

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width