0

I have this code:

<div class="dealOnContainer">

            <script type="text/javascript">
                product_countdown('25092', $('counterbox90'));
            </script>

</div>

and i'm trying whole day to catch seconds from this script ('25092') with regex but there is no idea. also i'm trying:

preg_match('#product_countdown(.*?)/#is', $string, $matches); 
  list($sekunde) = $matches;
  $data['sekunde'] = $sekunde; 

but doesnt work. Please Help me. (sorry for my english)

1
  • It's pretty hard to tell what you're trying to do. It looks like you're using PHP, but you didn't tag this question with php. I don't see any xpath at all, either. Commented Oct 25, 2011 at 15:45

1 Answer 1

2

You're matching from product_countdown(' until the nearest /, and that's much more than just the seconds part you're trying to match.

Try

#product_countdown\(\'(.*?)'\)#is

Now the .*? is forced to match between product_countdown(' and ').

Sign up to request clarification or add additional context in comments.

2 Comments

If that parameter only ever contains a single integer number, use #product_countdown\(\'(\d*)'\)#i instead. That would be even better.
The s is unnecessary since there are no dots in the regex (and the s parameter modifies how dots are interpreted).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.