0

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 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">
Daniel Vandersluis
  • 91,582
  • 23
  • 169
  • 153
kojoma
  • 313
  • 2
  • 3
  • 12

2 Answers2

2

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">([^<]+)

CrayonViolent
  • 32,111
  • 5
  • 56
  • 79
1

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 
djfoxmccloud
  • 571
  • 1
  • 9
  • 23