sowmiya Posted October 20, 2010 Share Posted October 20, 2010 $file=file("templates/index.html"); $rcontent=join("",$file); $rcontent=preg_replace("/{{(.*?)}}/e","$$1",$rcontent); // explain regular expression slone print $rcontent; Quote Link to comment Share on other sites More sharing options...
salathe Posted October 20, 2010 Share Posted October 20, 2010 It looks for anything enclosed in double-curly-braces (e.g. {{foobar}}) and replaces that with the value in the associated variable (e.g. $foobar). It's a very, very awful and crude token-replacement system. Quote Link to comment Share on other sites More sharing options...
sowmiya Posted October 22, 2010 Author Share Posted October 22, 2010 Repeats the previous item zero or more times. Lazy, so the engine first attempts to skip the previous item, before trying permutations with ever increasing matches of the preceding item. for eg: ".*?" matches "def" in abc "def" "ghi" jkl http://www.regular-expressions.info/reference.html Quote Link to comment Share on other sites More sharing options...
.josh Posted October 22, 2010 Share Posted October 22, 2010 Repeats the previous item zero or more times. Lazy, so the engine first attempts to skip the previous item, before trying permutations with ever increasing matches of the preceding item. for eg: ".*?" matches "def" in abc "def" "ghi" jkl http://www.regular-expressions.info/reference.html Which is effectively the same thing as saying "looks for anything enclosed in double-curly-braces" which salathe's description is overall better because he was explaining the code overall, not just a single bit of the actual pattern. If all you wanted to know was that specific thing, next time be more specific in explaining what you want to know. 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.