markvaughn2006 Posted December 2, 2012 Share Posted December 2, 2012 ...exampleleftside=thedataIwant">examplerightside How would one go about capturing the data I want from some html code similar to the one above? I know how and would be using file_get_contents, running a while loop, putting the captured data in a variable, and storing it to a database, I'm just not getting regex... Any help would be greatly appreciated, thanks! Link to comment https://forums.phpfreaks.com/topic/271469-find-string-between-two-strings/ Share on other sites More sharing options...
Christian F. Posted December 2, 2012 Share Posted December 2, 2012 From the very limited example you've given, which I'm not sure will be enough: $RegExp = '/=([^"]+)/'; That'll find an equals sign, then match and capture everything that is not a double quote, up to the first double quote it finds. (Then it's not not a quote any more, after all.) Link to comment https://forums.phpfreaks.com/topic/271469-find-string-between-two-strings/#findComment-1396813 Share on other sites More sharing options...
requinix Posted December 2, 2012 Share Posted December 2, 2012 If that's HTML then something involving DOM (like DOMDocument) would be better. Link to comment https://forums.phpfreaks.com/topic/271469-find-string-between-two-strings/#findComment-1396820 Share on other sites More sharing options...
markvaughn2006 Posted December 2, 2012 Author Share Posted December 2, 2012 From the very limited example you've given, which I'm not sure will be enough: $RegExp = '/=([^"]+)/'; That'll find an equals sign, then match and capture everything that is not a double quote, up to the first double quote it finds. (Then it's not not a quote any more, after all.) Anyway to make it find everything after the exampleleftside= up until the first double quote?? Thanks for the help! Link to comment https://forums.phpfreaks.com/topic/271469-find-string-between-two-strings/#findComment-1396903 Share on other sites More sharing options...
markvaughn2006 Posted December 2, 2012 Author Share Posted December 2, 2012 ok, it works, thanks people! Link to comment https://forums.phpfreaks.com/topic/271469-find-string-between-two-strings/#findComment-1396907 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.