probably simple regex help

Any questions involving matching text strings to patterns - the pattern is called a "regular expression."

Moderator: General Moderators

Post Reply
Directlinq
Forum Newbie
Posts: 1
Joined: Thu Sep 08, 2011 8:29 am

probably simple regex help

Post 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
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: probably simple regex help

Post by AbraCadaver »

Not tested:

Code: Select all

$regex = '/">\s+([^\s]+)/';
preg_match_all($regex, $htmldata, $matches);
print_r($matches[1]);
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Post Reply