unknown1 Posted January 18, 2014 Share Posted January 18, 2014 How would I go about finding this pattern? some random text http://www.somesite.com/en/bluhbluhbluh/?partner=compare&cy=EN woot 8.99 i tried [A-Za-z][\n]{0,}[http\://[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(/\S*)?]{0,}[\n]{0,}[A-Za-z0-9\.] only this part http\://[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(/\S*)?]{0,}[\n]{0,}[A-Za-z0-9\. is working to find the url but can't get everything else seems like anything i put before or after http\://[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(/\S*)? does nothing. Need to get "some random text" and "woot 8.99" in addition to the url Link to comment https://forums.phpfreaks.com/topic/285475-find-a-pattern/ Share on other sites More sharing options...
doddsey_65 Posted January 18, 2014 Share Posted January 18, 2014 Haven't tested this but maybe try (.*(?=http))(http:\/\/.*?(?=\s))(.*) Matches everything upto http, then matches http upto first whitespace character, then matches everything after it. Link to comment https://forums.phpfreaks.com/topic/285475-find-a-pattern/#findComment-1465689 Share on other sites More sharing options...
unknown1 Posted January 19, 2014 Author Share Posted January 19, 2014 (.*(?=http))(http:\/\/.*?(?=\s))(.*) works however, it doesn't stop after the 8.99 like it should. Link to comment https://forums.phpfreaks.com/topic/285475-find-a-pattern/#findComment-1465697 Share on other sites More sharing options...
doddsey_65 Posted January 19, 2014 Share Posted January 19, 2014 Wasn't aware you wanted it to stop. Will it always end in 8.99 or can the string change? Link to comment https://forums.phpfreaks.com/topic/285475-find-a-pattern/#findComment-1465698 Share on other sites More sharing options...
unknown1 Posted January 19, 2014 Author Share Posted January 19, 2014 it's always a number with the 8.99 format Link to comment https://forums.phpfreaks.com/topic/285475-find-a-pattern/#findComment-1465702 Share on other sites More sharing options...
doddsey_65 Posted January 20, 2014 Share Posted January 20, 2014 Sorry for the late reply. If you haven't sorted it yet you could use my example with a small change at the end (.*(?=http))(http:\/\/.*?(?=\s))(.*?)\d\.\d Link to comment https://forums.phpfreaks.com/topic/285475-find-a-pattern/#findComment-1465933 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.