PHP preg_replace를 사용하여 CSV 파일에서 일부 줄 바꿈을 삭제하려고합니다. 나는 그것을 얻지 않는다. 나는 많이 노력했다. 어쩌면 누군가 내 코드를 도와 줄 수 있습니다.CSV 내에서 preg_replace로 LF 제거
$content = "Halvah sweet ice.|Donut pastry candy canes bear claw toffee ice cream
cotton candy jelly-o. Pastry chocolate lemon drops biscuit muffin muffin apple pie croissant. Candy canes topping pudding biscuit. Cotton candy sweet mi bears chocolate. Croissant sesame snaps chocolate cake. Topping toffee oat cake cake. Biscuit| cheesecake powder";
$content = preg_replace('/^\|(.*)\n(.*)\|$/', "", $content);
// expected result
$content = "Halvah sweet ice.|Donut pastry candy canes bear claw toffee ice cream cotton candy jelly-o. Pastry chocolate lemon drops biscuit muffin muffin apple pie croissant. Candy canes topping pudding biscuit. Cotton candy sweet mi bears chocolate. Croissant sesame snaps chocolate cake. Topping toffee oat cake cake. Biscuit| cheesecake powder";
| | 예를 들어, "크림"이라는 단어 뒤에 줄 바꿈.
감사합니다.
경고에주의를 기울 였다면, * preg_replace() : 6 행의 /home/kVVTYTY/prog.php에서 알 수없는 수정 자 '\'가 표시 될 수 있습니다. * –
['$ content = preg_replace_callback ("/ \ | [} $ str_replace (array ("\ n", "\ r"), "", $ m [0] ;] (https://ideone.com/J0tdns). –
@ WiktorStribiżew 네 말이 맞아, 나는 오래된 코드 버전을 사용했다. 스택에서 예제/\\\\ n /을 찾았습니다. \ n 이스케이프 처리가 올바른지 확인하려고했습니다. – vine