我从textarea获取数据,用户必须在每行上输入一个名称。该数据后来在回车时被分割。有时用户可能会故意添加空行。我如何检测这些行并删除它们?我使用PHP。我不介意使用正则表达式或其他任何东西。 不正确的数据 Matthew
Mark
Luke
John
James
正确的数据(注意:删除空行) Matthew
Mark
Luke
John
James
可能重复: Removing carriage return and new-line from the end of a string in c# 如何删除在字符串末尾回车。 我已经谷歌了,但我找不到我需要的代码。 这是我当前的代码: 回报s.Replace( “\ n”, “”).Replace( “\ r”, “”).Replace( “\ r \ n”, “” )。修剪(); 但当然所有旧