Simple Regex question (~[^newline characters])

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • dk_sz

    Simple Regex question (~[^newline characters])

    <?
    // Test example:
    echo '<pre>';
    $aInput = '
    abtgh kdghg 9867 jkuhkh
    ^ {
    ooijj 438764 - 56_ 67
    ';
    $aInput = ereg_replace('[^\n\r]', ',' , $aInput);
    echo $aInput;
    echo '</pre>';

    Why doesn't this keep the newlines?
    Instead it converts everything into ','.
    ?>

    best regards
    Thomas


  • dk_sz

    #2
    Re: Simple Regex question (~[^newline characters])

    > $aInput = ereg_replace('[^\n\r]', ',' , $aInput);

    $aInput = preg_replace('/[^\r\n]/', ',', $aInput);



    best regards
    Thomas


    Comment

    • CC Zona

      #3
      Re: Simple Regex question (~[^newline characters])

      In article <3f05435b$0$761 16$edfadb0f@dre ad11.news.tele. dk>,
      "dk_sz" <dk_sz@hotmail. com> wrote:
      [color=blue]
      > $aInput = ereg_replace('[^\n\r]', ',' , $aInput);
      > echo $aInput;
      > echo '</pre>';
      >
      > Why doesn't this keep the newlines?
      > Instead it converts everything into ','.[/color]

      Put the pattern inside double-quotes instead of single quotes.

      --
      CC

      Comment

      Working...