fork download
  1. <?php
  2.  
  3. $text = "Today is | nice day | go to | school now | and enjoy | your life |.";
  4. echo $text; echo "\r\n\r\n";
  5.  
  6. $text = preg_replace("~\| (.*?) \|~", '"$1"', $text);
  7. echo $text; echo "\r\n\r\n";
Success #stdin #stdout 0.02s 26292KB
stdin
Standard input is empty
stdout
Today is | nice day | go to | school now | and enjoy | your life |.

Today is "nice day" go to "school now" and enjoy "your life".