PHP Regex: How to match \r and \n without using [\r\n]?

后端 未结 7 1128
予麋鹿
予麋鹿 2020-11-27 05:58

I have tested \\v (vertical white space) for matching \\r\\n and their combinations, but I found out that \\v does not match \\r

7条回答
  •  野性不改
    2020-11-27 06:35

    To match a newline in PHP, use the php constant PHP_EOL. This is crossplatform.

    if (preg_match('/\v+' . PHP_EOL ."/", $text, $matches ))
       print_R($matches );
    

提交回复
热议问题