SarkarG
SarkarG

Reputation: 687

Regex match group but don't include in result

I am trying to find a group of IDs from an web page html source code.

<!DOCTYPE html>
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
<head>
<body>
 <script type="text/javascript">
    //<![CDATA[
     jQuery(document).ready(function(){
     jQuery('#Grid').tGrid({
     pageSize:["5","10","20","50"],
     myIds: [1765,1706,1809,1847,1857], 
     add: 'url/add'}); });
    //]]>
 </script>
</body>
</html>

I wan't to extract all the values for myIds in this format 1765,1706,1809,1847,1857

So far tried these:

(myIds:\s)\[(.*?)\]

matches myIds: [1765,1706,1809,1847,1857]

(?!myIds:\s)\[(.*?)\]

matches [1765,1706,1809,1847,1857], ["5","10","20","50"], [if gt IE 8], [endif]

How can i get values of myIds.

Upvotes: 0

Views: 447

Answers (1)

vks
vks

Reputation: 67968

\s*myIds.*?\[(.*?)\]

This works.

See demo.

http://regex101.com/r/iX5xR2/20

Upvotes: 1

Related Questions