Page 1 of 1

probably simple regex help

Posted: Thu Sep 08, 2011 9:05 am
by Directlinq
Bare with me im a newb but im trying:-)

Could somebody please help me.
programming language: (PHP)
Task: (To filter out variables between certain characters in html code.)
So Far: I have created an expression (below) that gets the data i
need, but the characters i need to obtain the data '">' are also being
collected.I need the data after "> but do not need the "> as part of
the data collected.
I am using some php code to put the data collected into an array.

My Regex

Code: Select all

">\s+[^\s+]*
Phpcode to put it into an array

Code: Select all

preg_match_all ($regex, $htmldata, $matches);
Sample with data i need to extract(The normal html is longer than this
but the same patternn is repeated exactly apart from the data i need
The data i need is down the right side(>>4.7%     38     £11k     )

Code: Select all

<td align="center">
                                    >>4.7%
          </td>
<td align="center">
                                    38
      </td>
<td align="center">
                                    £11k
         </td>
</tr>



<td align="center">
                                    &nbsp;
          </td>
I hope somebody can help me??

Many Thanks                      &nbsp;
          </td>
[/syntax]

I hope somebody can help me??

Many Thanks

Re: probably simple regex help

Posted: Thu Sep 08, 2011 10:13 am
by AbraCadaver
Not tested:

Code: Select all

$regex = '/">\s+([^\s]+)/';
preg_match_all($regex, $htmldata, $matches);
print_r($matches[1]);