-2

I'm trying to find a regular expression to match a certain portion of this html code:

        <TR class="">
                <TD align=left>WebContainer : 312</TD>
                <TD align=left>hung</TD>
                <TD align=left>2014-06-13</TD>
                <TD align=right>08:20:14</TD>
                <TD align=right>-</TD>
                <TD align=right>01:57:46</TD>
        </TR>

And I need to match the exact bold string starting with the hyphen and ending at the </TD> tag.

Also, The 24hr clock in the bottom line needs 01 for the hour portion. I can figure out the clock portion as \d{1}1:\d{2}:\d{2} but as for grabbing the whole string including the newline I'm stuck. Please help?

Nishant
  • 54,584
  • 13
  • 112
  • 127
Andrew Bowler
  • 93
  • 1
  • 2
  • 7
  • 1
    You may find this Q&A informative (although it's not an exact duplicate so I'm not closing). http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags – Tim B Jun 13 '14 at 15:41

3 Answers3

0

This one select all text between wildcards in the \2 buffer

(\*\*)([^\1]+)\1

For a better comprehension, you can see this RE in regexper ;-)

You can use this one to extract all from hyphen to the next </TD> you'll find.

-(</TD>)([^\1]+)\1
Patrick Ferreira
  • 1,983
  • 1
  • 15
  • 31
0

For the part of the question asking how to match the newline, try

-</TD>\n.*<TD
Veedrac
  • 58,273
  • 15
  • 112
  • 169
vcosk
  • 2,894
  • 2
  • 23
  • 23
0

Just match the bold text:

/(?!(.*<\/TD){3})-<\/T.*\/TD>/s

Ensure hour is 01:

/(?!(.*<\/TD){3})-<\/T.*01[0-9:]{6}<\/TD>/s

Where the s modifier is dot matches newline

Tested here: http://regex101.com/r/sZ6qU5

Devon Parsons
  • 1,234
  • 14
  • 23