What I’m trying to do here is take a string that might have what would normally be a code comment, and replace that with something else, especially wrapping it in something else. I’m pretty sure the preg_replace function would work here, but I don’t have an idea on where to start with the Regex. For example:
Hello world //this is a comment
Testing //not testing
Test again
Would turn into
Hello world %//this is a comment%
Testing %//not testing%
Test again
preg_replace('???', '%$1%', $matches); is as much as I can figure out on my own, any help is much appreciated!
This will remove everything after (and including)
//to the end of the linehttp://ideone.com/Xhmpd
This will wrap them with
foo bararoundhttp://ideone.com/IqkWM