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); Link to comment https://forums.phpfreaks.com/topic/265671-ergei-to-preg_match/ Share on other sites More sharing options...
scootstah Posted July 14, 2012 Share Posted July 14, 2012 Presumably: preg_match("/$begin(.*)$finish/", $stuff, $cont); Link to comment https://forums.phpfreaks.com/topic/265671-ergei-to-preg_match/#findComment-1361513 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. Link to comment https://forums.phpfreaks.com/topic/265671-ergei-to-preg_match/#findComment-1361515 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. Link to comment https://forums.phpfreaks.com/topic/265671-ergei-to-preg_match/#findComment-1361516 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 Link to comment https://forums.phpfreaks.com/topic/265671-ergei-to-preg_match/#findComment-1361518 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! Link to comment https://forums.phpfreaks.com/topic/265671-ergei-to-preg_match/#findComment-1361590 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 Link to comment https://forums.phpfreaks.com/topic/265671-ergei-to-preg_match/#findComment-1361592 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 Link to comment https://forums.phpfreaks.com/topic/265671-ergei-to-preg_match/#findComment-1363439 Share on other sites More sharing options...
scootstah Posted July 22, 2012 Share Posted July 22, 2012 Yes. Link to comment https://forums.phpfreaks.com/topic/265671-ergei-to-preg_match/#findComment-1363458 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.