help with replace "" with " " in a string

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • chriskaza81
    New Member
    • Nov 2007
    • 52

    #1

    help with replace "" with " " in a string

    helo all

    i have a string blablabla""blab la"" i want to make a space between two double qoates like blablabla" "blabla" "

    how can i do it in java .. i use replaceAll function but i can't find thw way to do that.
  • Ganon11
    Recognized Expert Specialist
    • Oct 2006
    • 3651

    #2
    You can use the .find operator to find an occurrence of "", then use concatenation to add the space character.

    Comment

    • chriskaza81
      New Member
      • Nov 2007
      • 52

      #3
      Originally posted by Ganon11
      You can use the .find operator to find an occurrence of "", then use concatenation to add the space character.

      i found an alternative method ...
      but thanks anyway

      Comment

      • BigDaddyLH
        Recognized Expert Top Contributor
        • Dec 2007
        • 1216

        #4
        If you do not need to use proper regexes -- if you are doing a straight substring replacement -- prefer String method replace over replaceAll.

        String.replace API

        Despite its name, replace does replace all occurrences of the first argument with the second:[CODE=Java]String result = s.replace("\"\" ", "\" \"");[/CODE]The only tricky thing in this example is to remember to escape the double quote, since it is a delimiter.

        Comment

        Working...