Jump to content

[SOLVED] Two wildcards


Asheeown

Recommended Posts

I currently have this string

preg_match('/data: (.*);/', $Contents, $Matches);

 

It doesn't work the way I want it to because sometimes data: 'wildcard'; appears more than once, I need more info behind the word data so it should look like this:

 

new Listview({template: 'item', id: 'sells', name: LANG.tab_sells, tabs: tabsRelated, parent: 'WILDCARD', extraCols: [Listview.extraCols.cost], note: WILDCARD, data:

 

Wherever WILDCARD appears it just needs to be set to a wildcard.  Problem is I wasn't the original person to right this regex code I just modded it to fit my needs but I tried to do this one and the array $Matches comes up empty everytime.  Can anyone help?

Link to comment
https://forums.phpfreaks.com/topic/151994-solved-two-wildcards/
Share on other sites

Sorry i'm a little confused..

what are you trying to check for ?

maybe a few examples and bolding the thing you need to check for..

are you trying to get the data between "data: " and the ";" ?

if so try this

preg_match_all('/data: ([^;]*);/s', $Contents, $Matches, PREG_PATTERN_ORDER);
$Matches= $Matches[1];
echo "<pre>";
var_dump($Matches);

Link to comment
https://forums.phpfreaks.com/topic/151994-solved-two-wildcards/#findComment-798226
Share on other sites

You got it:

 

Here is the full string of data inside all the text:

new Listview({template: 'item', id: 'sells', name: LANG.tab_sells, tabs: tabsRelated, parent: 'lkljbjkb574', extraCols: [Listview.extraCols.cost], note: sprintf(LANG.lvnote_createafilter, '/?items&filter=cr=129;crs=0;crv=66'), data: [{id:5956,name:'6Blacksmith Hammer',level:1,reqlevel:1,dps:0.8,speed:2.00,slot:21,source:[5],classs:2,subclass:14,stack:[1],avail:-1,cost:[18]},{id:2324,name:'6Bleach',level:5,slot:0,source:[5],classs:7,subclass:11,stack:[1],avail:-1,cost:[25]},{id:6260,name:'6Blue Dye',level:10,slot:0,source:[5],classs:7,subclass:11,stack:[1],avail:-1,cost:[50]},{id:2320,name:'6Coarse Thread',level:5,slot:0,source:[5],classs:7,subclass:5,stack:[1],avail:-1,cost:[10]},{id:10648,name:'6Common Parchment',level:40,slot:0,source:[5],classs:7,subclass:11,stack:[1],avail:-1,cost:[125]},{id:6217,name:'6Copper Rod',level:5,slot:0,source:[5],classs:7,subclass:12,stack:[1],avail:-1,cost:[124]},{id:3371,name:'6Empty Vial',level:1,slot:0,source:[2,5],sourcemore:[{t:7,ti:4395,n:'Dalaran'}],classs:7,subclass:11,stack:[5],avail:-1,cost:[20]},{id:6256,name:'6Fishing Pole',level:1,dps:1.0,speed:3.00,slot:17,source:[4,5],sourcemore:[{t:5,ti:9452,n:'Red Snapper - Very Tasty!',c:3524,c2:1}],classs:2,subclass:20,stack:[1],avail:-1,cost:[23]},{id:39354,name:'6Light Parchment',level:1,slot:0,source:[5],classs:7,subclass:11,stack:[1],avail:-1,cost:[15]},{id:2678,name:'6Mild Spices',level:5,slot:0,source:[5],classs:7,subclass:11,stack:[5],avail:-1,cost:[10]},{id:2901,name:'6Mining Pick',level:4,reqlevel:1,dps:1.5,speed:2.00,slot:21,source:[5],classs:2,subclass:14,stack:[1],avail:-1,cost:[81]},{id:6270,name:'6Pattern: Blue Linen Vest',level:12,slot:0,skill:55,source:[5],classs:9,subclass:2,stack:[1],avail:1,cost:[200]},{id:6325,name:'6Recipe: Brilliant Smallfish',level:5,slot:0,skill:1,source:[5],classs:9,subclass:5,stack:[1],avail:-1,cost:[40]},{id:6328,name:'6Recipe: Longjaw Mud Snapper',level:15,slot:0,skill:50,source:[5],classs:9,subclass:5,stack:[1],avail:-1,cost:[400]},{id:2604,name:'6Red Dye',level:10,slot:0,source:[5],classs:7,subclass:11,stack:[1],avail:-1,cost:[50]},{id:4289,name:'6Salt',level:10,slot:0,source:[5],classs:7,subclass:6,stack:[1],avail:-1,cost:[50]},{id:6529,name:'6Shiny Bauble',level:10,slot:0,source:[4,5],sourcemore:[{t:5,ti:9452,n:'Red Snapper - Very Tasty!',c:3524,c2:1}],classs:0,subclass:-3,stack:[1],avail:-1,cost:[50]},{id:30817,name:'6Simple Flour',level:5,slot:0,source:[5],classs:7,subclass:11,stack:[5],avail:-1,cost:[25]},{id:7005,name:'6Skinning Knife',level:4,reqlevel:1,dps:1.3,speed:1.60,slot:13,source:[2,5],sourcemore:[{t:3,ti:33857,n:'Crate of Meat',q:1}],classs:2,subclass:14,stack:[1],avail:-1,cost:[82]},{id:2880,name:'6Weak Flux',level:5,slot:0,source:[5],classs:7,subclass:11,stack:[1],avail:-1,cost:[100]}]});

 

I need everything from data: to the semicolon at the end the parent ID "parent: 'lkljbjkb574'" is never the same so that needs to be a wildcard and also "/?items&filter=cr=129;crs=0;crv=66" is never the same so that needs to be a wildcard also.

Link to comment
https://forums.phpfreaks.com/topic/151994-solved-two-wildcards/#findComment-798307
Share on other sites

what are you trying to check for ?

by the sounds of thing you just want to check its valid!.. but also you want to extract details!

telling me its changes and need to be a wildcard (i know what wildcard is thus if it changes i know its going to be a wildcard)

 

With all that in-mind i'll have to assume you want

 

parent:' to '

sprintf(LANG.lvnote_createafilter, ' to ')

data: to ;

 

i'll also assume the order is the seam each time!

in that case

 

try

<?php
preg_match('/parent:\s*\'([^\']*)\'.*?sprintf\(LANG.lvnote_createafilter, \'([^\']*)\'\).*?data: ([^;]*);/si', $Contents, $Matches)
$parent= $Matches[1];
$createafilter= $Matches[2];
$data= $Matches[3];
}
?>

Link to comment
https://forums.phpfreaks.com/topic/151994-solved-two-wildcards/#findComment-798330
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.