Jump to content

a little help please!


daydreamer

Recommended Posts

I am trying to get a number from a string that will be in the range of 0.00 to 99.99.

 

It will occur in the string like this:

 

   <p><em class="example">
			                     3.30
							</em></p>

 

spaces included!

 

here is what i have so far:

 

<?php
preg_match("/(?=\"example\"> \s)[0-9]\.[0-9][0-9]+/",$xxx,$matches);
print_r($matches);
?>

 

What do i need to change?

 

thanks.

Link to comment
Share on other sites

Perhaps I'm splitting hairs here (I get the sense I am).. but I noticed the dot is not escaped in the pattern (thus it will capture any single character between the set of digits). depending on the data found in <em class="example">, the current pattern could find '3-30' for example. If there is a possibility to have something other than the dot between digits, would you not need to escape it in the pattern?

 

preg_match('/<em class="example">\s*(\d{1,2}\.\d{2})/', $data, $matches);

 

But again, depending on how the data that is found in <em class="example"> is decided / filtered, it probably doesn't matter?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.