Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
$string ="string string //deleteme string //deleteme // deleteme string";
如何删除所有以双斜杠开头的行?
我想你应该使用 preg_replace 用空字符串替换单词/行。就像是:
$regex = '/ \/\/ [^\n]* \n /'; preg_replace($regex, '', $string);
删除整行:
$string = preg_replace('/\/\/\S*[^\n]+\n?/','',$string);