dsaba Posted May 27, 2007 Share Posted May 27, 2007 i get this error: Warning: preg_replace(): Compilation failed: missing terminating ] for character class at offset 8 on line 53 here is a snippet of problem code: $constant = strtolower(add_underscores($searchfor)); $constantized = concactenate($constant); //makes: '.Hello_World.' if (strpos($source_code, $searchfor_slashes) != FALSE) { $source_code = str_replace($searchfor_slashes, $constantized, $source_code); $source_code = preg_replace('/[^\\]\'\.?/', '', $source_code); // line 53 //$source_code = str_replace("''.", "", $source_code); $source_code = str_replace(".''", "", $source_code); echo 'Concactenated: <b>'.$constant.'</b> in <em>'.$file.'</em>'; echo 'finished if space was two in '.$file.'<br>'; anyone know how to fix this error? i dont understand i've used this regex several times before and have never gotten this error until now, very odd indeed... Quote Link to comment https://forums.phpfreaks.com/topic/53156-regex-error-with-preg_replace/ Share on other sites More sharing options...
neel_basu Posted May 27, 2007 Share Posted May 27, 2007 Just looking at the regex. --------------------------- "/[^\\]'\.?/" try using Double quote instead of Single quote Can you send a string what you wanna match ?? Quote Link to comment https://forums.phpfreaks.com/topic/53156-regex-error-with-preg_replace/#findComment-262593 Share on other sites More sharing options...
MadTechie Posted May 27, 2007 Share Posted May 27, 2007 you mean /[^\]\\'\.?/ $source_code = preg_replace('/[^\]\\'\.?/im', '', $source_code); IM for case and linematch Quote Link to comment https://forums.phpfreaks.com/topic/53156-regex-error-with-preg_replace/#findComment-262595 Share on other sites More sharing options...
dsaba Posted May 27, 2007 Author Share Posted May 27, 2007 i don't get your reply mad but this is wrong look at the highlighting $source_code = preg_replace('/[^\]\\'\.?/im', '', $source_code); Quote Link to comment https://forums.phpfreaks.com/topic/53156-regex-error-with-preg_replace/#findComment-262597 Share on other sites More sharing options...
MadTechie Posted May 27, 2007 Share Posted May 27, 2007 true, should of tested, try this <?php $source_code = preg_replace("/[^\]\\'\.?/im", '', $source_code); ?> Quote Link to comment https://forums.phpfreaks.com/topic/53156-regex-error-with-preg_replace/#findComment-262600 Share on other sites More sharing options...
dsaba Posted May 27, 2007 Author Share Posted May 27, 2007 still get same error, wiht double quotes on original regex and with the new one Quote Link to comment https://forums.phpfreaks.com/topic/53156-regex-error-with-preg_replace/#findComment-262603 Share on other sites More sharing options...
MadTechie Posted May 27, 2007 Share Posted May 27, 2007 $source_code = preg_replace("/[^\\\]\'\.?/", '', $source_code); // line 53 Quote Link to comment https://forums.phpfreaks.com/topic/53156-regex-error-with-preg_replace/#findComment-262606 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.