0

我要直入主题了

这是我的模式:

/Day [0-9]+:(.*?)Day [0-9]+:/s

这是我的主题:

                Day 1:

House:
Song Name:
Artist:
Facebook Page:
Soundcloud Page:
Free Download:
Download Link:
Youtube Link:
Description:
Date added to youtube:

Moombahton:
Song Name:
Artist:
Facebook Page:
Soundcloud Page:
Free Download:
Download Link:
Youtube Link:
Description:
Date added to youtube:

Dubstep:
Song Name: Clap Your Hands
Artist: Walk Home
Facebook Page: https://www.facebook.com/walkhomemusic
Soundcloud Page: https://soundcloud.com/walk-home
Free Download: Yes
Download Link: http://www.mediafire.com/?usi4rtx9q26owbn
Youtube Link: http://www.youtube.com/watch?v=kqfDM1aNjp4
Description: Walk Home really killed it with this song. I especially like this song for the ability to take it across genres. There is a really nice guitar solo in the drop, and I think that is what makes this song. The mixture of analog and digital instruments is phenomenal. The entire song will be a treat to any listener, whether they like Rock, or electronic music. 
Date added to youtube: March 6th, 2013

Glitch Hop:
Song Name:
Artist:
Facebook Page:
Soundcloud Page:
Free Download:
Download Link:
Youtube Link:
Description:
Date added to youtube:

DnB:
Song Name:
Artist:
Facebook Page:
Soundcloud Page:
Free Download:
Download Link:
Youtube Link:
Description:
Date added to youtube:

Other:
Song Name:
Artist:
Facebook Page:
Soundcloud Page:
Free Download:
Download Link: 
Youtube Link:
Description:
Date added to youtube:


Day 2:

House:
Song Name: No Expectations
Artist: Hollidayrain
Facebook Page: https://www.facebook.com/HollidayrainMusic
Soundcloud Page: https://soundcloud.com/hollidayrain
Free Download: Yes
Download Link: http://www.mediafire.com/?z2du038l70f7n8s
Youtube Link: http://www.youtube.com/watch?v=VDRl39n1rFQ
Description: Hollidayrain has achieved a new standard in mixing and production with his soon to be hit song No Expectations. The clear and hard hitting drums really emphasize the dirty bass that this amazing electro house song has to offer. It’s clear that Hollidayrain will be on everyone’s radar. Keep a lookout for more great hits from him!
Date added to youtube: March 7, 2013

Moombahton:
Song Name:
Artist:
Facebook Page:
Soundcloud Page:
Free Download:
Download Link: 
Youtube Link:
Description:
Date added to youtube:

Dubstep:
Song Name:
Artist:
Facebook Page:
Soundcloud Page:
Free Download:
Download Link: 
Youtube Link:
Description:
Date added to youtube:

Glitch Hop:
Song Name:
Artist:
Facebook Page:
Soundcloud Page:
Free Download:
Download Link: 
Youtube Link:
Description:
Date added to youtube:

DnB:
Song Name:
Artist:
Facebook Page:
Soundcloud Page:
Free Download:
Download Link: 
Youtube Link:
Description:
Date added to youtube:

Other:
Song Name:
Artist:
Facebook Page:
Soundcloud Page:
Free Download:
Download Link: 
Youtube Link:
Description:
Date added to youtube:

Day 3:

这是我从该模式得出的结果:

    array (
  0 => 
  array (
    0 => 'Day 1:

House:
Song Name:
Artist:
Facebook Page:
Soundcloud Page:
Free Download:
Download Link:
Youtube Link:
Description:
Date added to youtube:

Moombahton:
Song Name:
Artist:
Facebook Page:
Soundcloud Page:
Free Download:
Download Link:
Youtube Link:
Description:
Date added to youtube:

Dubstep:
Song Name: Clap Your Hands
Artist: Walk Home
Facebook Page: https://www.facebook.com/walkhomemusic
Soundcloud Page: https://soundcloud.com/walk-home
Free Download: Yes
Download Link: http://www.mediafire.com/?usi4rtx9q26owbn
Youtube Link: http://www.youtube.com/watch?v=kqfDM1aNjp4
Description: Walk Home really killed it with this song. I especially like this song for the ability to take it across genres. There is a really nice guitar solo in the drop, and I think that is what makes this song. The mixture of analog and digital instruments is phenomenal. The entire song will be a treat to any listener, whether they like Rock, or electronic music. 
Date added to youtube: March 6th, 2013

Glitch Hop:
Song Name:
Artist:
Facebook Page:
Soundcloud Page:
Free Download:
Download Link:
Youtube Link:
Description:
Date added to youtube:

DnB:
Song Name:
Artist:
Facebook Page:
Soundcloud Page:
Free Download:
Download Link:
Youtube Link:
Description:
Date added to youtube:

Other:
Song Name:
Artist:
Facebook Page:
Soundcloud Page:
Free Download:
Download Link: 
Youtube Link:
Description:
Date added to youtube:


Day 2:',
  ),
  1 => 
  array (
    0 => '

House:
Song Name:
Artist:
Facebook Page:
Soundcloud Page:
Free Download:
Download Link:
Youtube Link:
Description:
Date added to youtube:

Moombahton:
Song Name:
Artist:
Facebook Page:
Soundcloud Page:
Free Download:
Download Link:
Youtube Link:
Description:
Date added to youtube:

Dubstep:
Song Name: Clap Your Hands
Artist: Walk Home
Facebook Page: https://www.facebook.com/walkhomemusic
Soundcloud Page: https://soundcloud.com/walk-home
Free Download: Yes
Download Link: http://www.mediafire.com/?usi4rtx9q26owbn
Youtube Link: http://www.youtube.com/watch?v=kqfDM1aNjp4
Description: Walk Home really killed it with this song. I especially like this song for the ability to take it across genres. There is a really nice guitar solo in the drop, and I think that is what makes this song. The mixture of analog and digital instruments is phenomenal. The entire song will be a treat to any listener, whether they like Rock, or electronic music. 
Date added to youtube: March 6th, 2013

Glitch Hop:
Song Name:
Artist:
Facebook Page:
Soundcloud Page:
Free Download:
Download Link:
Youtube Link:
Description:
Date added to youtube:

DnB:
Song Name:
Artist:
Facebook Page:
Soundcloud Page:
Free Download:
Download Link:
Youtube Link:
Description:
Date added to youtube:

Other:
Song Name:
Artist:
Facebook Page:
Soundcloud Page:
Free Download:
Download Link: 
Youtube Link:
Description:
Date added to youtube:


',
  ),
)

我的预期结果是将第 1 天的帖子、第 2 天的帖子、第 n 天的帖子全部分开(在结果数组中)。它应该工作。查询显然找到了一些东西。但我不确定发生了什么。也许比我更聪明的人可以引导我朝着正确的方向前进!

4

1 回答 1

0

找到匹配项时会丢弃回溯信息,因此无法判断该组之前的迭代匹配Day [0-9]+: 使用Day [0-9]+:作为分隔符是危险的。最后一个条目呢?它不符合标准。如果文本包含“第 1 天:”怎么办?

查看您的示例很难选择另一个分隔符。如果您可以保证天之间的分隔符,例如 3 次或更多返回,则可以将其用作结束分隔符:

/Day [0-9]+:(.*?)\n{3,}/s
于 2013-03-08T04:06:32.860 回答