作者iFEELing (ing)
看板perl
标题[问题] 关於含空白的跨行比对样式-该如何写?
时间Thu Sep 21 18:26:22 2006
请教各位前辈
现在小弟碰到的问题是:
我用 lynx 去向某网站要回一个网页,放在 $str 中,
打算要由$str中抓出其中一段的资料。
它的资料格式是这样
blahblahblahblah
[3.jpg]
栏位1 栏位2 栏位3 栏位4
资料1 资料2 资料3 资料4
[4.jpg]blahblahblahblah
我试过 if($str =~ /(3.jpg)(.)(4.jpg)/s)
跟 if($str =~ /(3.jpg)([\s\S]*)(4.jpg)/s)
但是都没有比对成功。想请教在这样的状况下(要取的字串包括字元、空白跟换行),
REGEX 该怎麽写呢?
--
And they... Will dance if they want to dance Please brother take a chance
You know they're gonna go Which way they wanna go
All we know is that we don't know
What is gonna be Please brother let it be
Life on the other hand won't let you understand
Why we're all part of the masterplan _
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 163.22.18.89
※ 编辑: iFEELing 来自: 163.22.18.89 (09/21 18:26)
1F:推 abliou:其实有点看不懂你想抓的资料..可以再讲清楚点吗? 09/21 21:44
喔耶
用
/(\[3.jpg\])(.*)(\[4.jpg\])/s
就抓出中间的字串了 :)
感谢您的回应 ^^
※ 编辑: iFEELing 来自: 220.134.244.196 (09/21 22:33)