开发者

Quick help with a regex

I'm trying to use a regex but somehow it won't work. I've used a similar string in the past and it worked without problems.

old: (?<=(<img(.+)src=(.+)images(.+)statusicon/(.+)alt=\"))(.+)(?=( is(.+)line\")) new: (?<=(<span class=\"date\">))(.+)(?=(<span class=\"time\">))

I want开发者_JAVA技巧 it to find the date...


input:

<span class="postdate old">
    <span class="date">27.03.11 <span class="time">15:04</span></span>
</span>
<span class="nodecontrols">


Okay based on your cleaned up OP, your new pattern works, date is just in group 2. But here is a cleaned up regex (and it's in group 1)

<span class="date">((?:(?!<span).)+)

or even

<span class="date">([^<]+)


Aren't token separated by a space ? Meaning that

<span class="date">27.03.11 <span class="time">15:04  

isn't recognized because the string is not ended ? Does it work on

<span class="date">27.03.11 <span class="time"> 15:04 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜