0

我正在尝试使用 preg_match_all 从文本数组格式中提取数组:

解释:我有这种文本

mynicetext
text with other elements
|my first Column            |my second column   |
|my data in first column    |data 2             |    
|my data in first column    |data 3             |       
....   
other text
text with other elements
|my first Column            |my second column   | My last column |
|my data in first column    |data 2             |data 2          |     
|my data in first column    |data 3             |data 2          |
....

我想像这样提取一个完整的数组:

|my first Column            |my second column   |
|my data in first column    |data 2             |    
|my data in first column    |data 3             | 

我试图用它~(\s*\n)\|(.*)\|(\s*\n)~来提取,但我剪掉了由回车引起的线条。

|my first Column            |my second column   |

然后

|my data in first column    |data 2             | 

...

任何想法?

4

1 回答 1

1

你可以用 preg_match_all 试试这个:

$pattern = '~(?:^\|.*\n)+~m';
于 2013-08-06T09:42:48.003 回答