Quantcast
Viewing all articles
Browse latest Browse all 10

How to use preg_replace to replace phrase between question marks

<?php
$string = “?This is a test that should be in single quotes quotes?”;
$text = preg_replace(”/(\?([^\?]+)\?)/”,”‘\\2′”,$string);
?>

regular expression produces:

This is a test that should be in single quotes’


Viewing all articles
Browse latest Browse all 10

Trending Articles