How can i replace CRLF and Tabulation with space

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • manjava
    New Member
    • Sep 2009
    • 132

    How can i replace CRLF and Tabulation with space

    so i have this string;
    "ContenuCRL F
    text1

    text2 "

    and i want the first CRLF and tabulation replace by space i want use experssion reguler but i don't know

    Thanks in advance
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    no need to use a RegExp. use str_replace().

    Comment

    • manjava
      New Member
      • Sep 2009
      • 132

      #3
      i used that
      Code:
      preg_replace('/(^.+)(\r\n\t)/ime', "str_replace('$2', ' ', '$0')", $text)
      for this string http://i.stack.imgur.com/UasBL.png

      but not worked for me .thanks in advance

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #4
        but not worked for me
        you’re making that way to complicated. as I said you don’t even need regular expression. just the str_replace() function will do.

        Comment

        • manjava
          New Member
          • Sep 2009
          • 132

          #5
          yes i used just the str_replace
          Code:
          echo str_replace(chr(13).chr(10).chr(9), ' ',  $chaine);
          and also
          Code:
          echo str_replace("\r\n\t", ' ',  $chaine);
          but not worked for me thanks in advance

          Comment

          • Dormilich
            Recognized Expert Expert
            • Aug 2008
            • 8694

            #6
            but not worked for me
            I explained to you last time why that didn’t work and I also pointed out a solution.

            Comment

            • manjava
              New Member
              • Sep 2009
              • 132

              #7
              i var_dumped the output and copy to notpad++ and see nothing change i have the same of the string

              Comment

              • Dormilich
                Recognized Expert Expert
                • Aug 2008
                • 8694

                #8
                I told you why.

                Comment

                • manjava
                  New Member
                  • Sep 2009
                  • 132

                  #9
                  i don't know i do
                  Code:
                  $var=str_replace(chr(13).chr(10).chr(9), ' ',  $chaine);
                  i
                  Code:
                  var_dump($var);
                  i have the same of my screen shot nothing change

                  Comment

                  • Dormilich
                    Recognized Expert Expert
                    • Aug 2008
                    • 8694

                    #10
                    it would help to actually read the documentation of str_replace() because the solution is demonstrated right in the first example (block).

                    Comment

                    Working...