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! Quote 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.) Quote 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. Quote 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! Quote 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! Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.