lordshoa Posted July 14, 2012 Share Posted July 14, 2012 Need to change from ergi to preg_match if some one is good with regex thanks for any help eregi("$begin(.*)$finish", $stuff, $cont); Quote Link to comment Share on other sites More sharing options...
scootstah Posted July 14, 2012 Share Posted July 14, 2012 Presumably: preg_match("/$begin(.*)$finish/", $stuff, $cont); Quote Link to comment Share on other sites More sharing options...
lordshoa Posted July 14, 2012 Author Share Posted July 14, 2012 I am sure I have tried that and loads of other variations of it but will give it another go. Will have to wwrite them down as I go this time as not to keep trying the same thing. Just gave it ago and the output is blank. Quote Link to comment Share on other sites More sharing options...
scootstah Posted July 14, 2012 Share Posted July 14, 2012 Well, I don't know what $begin and $finish hold, so I'm only guessing here. Quote Link to comment Share on other sites More sharing options...
lordshoa Posted July 14, 2012 Author Share Posted July 14, 2012 they just hold a $var that is the start for the search and the end of the search So If i was searching in a txt file it would look for the the word start say $begining - 'start'; $finish = 'end'; search for the word start hold everything in between untill you find the word end from the file $stuff add eveything inbetween to the var $cont Quote Link to comment Share on other sites More sharing options...
.josh Posted July 15, 2012 Share Posted July 15, 2012 Only thing really to add to scootah's code is the i modifier, since eregi is case-insensitive. Also $begin = preg_quote($begin,"/"); $finish = preg_quote($finish,"/"); preg_match("/$begin(.*)$finish/i", $stuff, $cont); edit: I had edited to add preg_quote at same time as xyph's post! Quote Link to comment Share on other sites More sharing options...
xyph Posted July 15, 2012 Share Posted July 15, 2012 It's probably worth it to preg_quote $begin and $finish Quote Link to comment Share on other sites More sharing options...
lordshoa Posted July 22, 2012 Author Share Posted July 22, 2012 I figured it out was messing about and it needed the s modifier. Can more than one modifier be used at a time ? Thanks for your help Quote Link to comment Share on other sites More sharing options...
scootstah Posted July 22, 2012 Share Posted July 22, 2012 Yes. Quote Link to comment 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.