vlada a
vlada a

Reputation: 1

Regex from javascript

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)

Upvotes: 0

Views: 58

Answers (1)

Tim Pietzcker
Tim Pietzcker

Reputation: 336158

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 ').

Upvotes: 2

Related Questions