nadeemshafi9 Posted October 28, 2009 Share Posted October 28, 2009 hi guys can somone give me some links to some solid manuals this is my string #image,100# i need to get the 100 any ideas im just about to dl a cheetsheet will be back soon to see what has been suggested, this is the first regex of this new job of mine so iim slightly out of knowledge on it atm, was using it a lot at the last job http://www.addedbytes.com/cheat-sheets/regular-expressions-cheat-sheet/ should be bale to knock something up i n a bit Link to comment https://forums.phpfreaks.com/topic/179345-simple-pregmatch-inverted/ Share on other sites More sharing options...
salathe Posted October 28, 2009 Share Posted October 28, 2009 Let us know how you get on after reading/using the cheat sheet and we'll be able to move forwards from there. Link to comment https://forums.phpfreaks.com/topic/179345-simple-pregmatch-inverted/#findComment-946267 Share on other sites More sharing options...
nadeemshafi9 Posted October 28, 2009 Author Share Posted October 28, 2009 cool Link to comment https://forums.phpfreaks.com/topic/179345-simple-pregmatch-inverted/#findComment-946269 Share on other sites More sharing options...
nadeemshafi9 Posted October 28, 2009 Author Share Posted October 28, 2009 this is my string #image,100# i cant find anything to negate /#image.*#/ regexp, so im thinking its the wrong way to go about it, do i really need regex in this ? split the string by , strip off #image and # actualy if i can negate regexp /#image.*#/ i can then split the result by , Link to comment https://forums.phpfreaks.com/topic/179345-simple-pregmatch-inverted/#findComment-946276 Share on other sites More sharing options...
nadeemshafi9 Posted October 28, 2009 Author Share Posted October 28, 2009 this is my string #image,100, 200, baseline# maybe /[^#image.*#]/ or /[^#image].*[#]/ split(",",result) Link to comment https://forums.phpfreaks.com/topic/179345-simple-pregmatch-inverted/#findComment-946280 Share on other sites More sharing options...
nadeemshafi9 Posted October 28, 2009 Author Share Posted October 28, 2009 or /#image?!.*#?!/ Link to comment https://forums.phpfreaks.com/topic/179345-simple-pregmatch-inverted/#findComment-946285 Share on other sites More sharing options...
cags Posted October 28, 2009 Share Posted October 28, 2009 I take it it always says #image then? You could simply use trim to remove the hashes then explode on the comma. But if you want to use Regular Expressions then something like... ~^#image,(\d{3})#~ That of course assumes the 100 is always a 3 digit number. You can modify that accordingly. Link to comment https://forums.phpfreaks.com/topic/179345-simple-pregmatch-inverted/#findComment-946286 Share on other sites More sharing options...
nadeemshafi9 Posted October 28, 2009 Author Share Posted October 28, 2009 /^#image(.*)#$/ Link to comment https://forums.phpfreaks.com/topic/179345-simple-pregmatch-inverted/#findComment-946313 Share on other sites More sharing options...
nadeemshafi9 Posted October 28, 2009 Author Share Posted October 28, 2009 I take it it always says #image then? You could simply use trim to remove the hashes then explode on the comma. But if you want to use Regular Expressions then something like... ~^#image,(\d{3})#~ That of course assumes the 100 is always a 3 digit number. You can modify that accordingly. thanku Link to comment https://forums.phpfreaks.com/topic/179345-simple-pregmatch-inverted/#findComment-946314 Share on other sites More sharing options...
nadeemshafi9 Posted October 28, 2009 Author Share Posted October 28, 2009 the string background-image: url(#picture,100,100#); the regex preg_match("~[#picture],.*[#]~", $html, $result); print_r($result); the result Array ( [0] => e,100,100# ) what i expect Array ( [0] => 100,100) help plzzz Link to comment https://forums.phpfreaks.com/topic/179345-simple-pregmatch-inverted/#findComment-946379 Share on other sites More sharing options...
nadeemshafi9 Posted October 28, 2009 Author Share Posted October 28, 2009 preg_match("/#picture(.*)#/", $html, $result); Array ( [0] => #picture,100,100# [1] => ,100,100 ) got it !!!! Link to comment https://forums.phpfreaks.com/topic/179345-simple-pregmatch-inverted/#findComment-946381 Share on other sites More sharing options...
MadTechie Posted October 28, 2009 Share Posted October 28, 2009 #picture(.*)# should be #picture,(.*?)# or better still #picture,(\d+,\d+)# but if you want to match all of these #picture,100# #picture,100,100# #picture,100,100,100# #picture,100,100,100,100# etc etc etc then this would be better #picture,(\d+(?:,\d+)*)# Link to comment https://forums.phpfreaks.com/topic/179345-simple-pregmatch-inverted/#findComment-946394 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.