我会直截了当地说,
这是我的模式:
/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天帖子全部分开(在结果数组中)。它应该工作。查询显然找到了一些东西。但我不确定发生了什么。也许比我更聪明的人可以引导我朝着正确的方向前进!
答案 0 :(得分:0)
当找到匹配时,将丢弃回溯信息,因此在该组具有与Day [0-9]+:
匹配的前一次迭代之后无法判断使用Day [0-9]+:
作为分隔符是危险的。最后一个条目怎么样?它不符合标准。如果文字包含“第1天:”怎么办?
看看你的样本,很难找到另一个分隔符。如果您可以保证日期之间的分隔符,例如3次或更多次返回,则可以将其用作结束分隔符:
/Day [0-9]+:(.*?)\n{3,}/s