regex - preg_replace to find and replace a string in php -


this question exact duplicate of:

using preg_replace find symbols + or - contains inside of string, if found means replace string double quote("") or single quote('').

for eg:

1.if sometext+sometext replace "sometext+sometext"

2.if sometext-sometext replace "sometext-sometext"

try following code:

echo preg_replace('/\b\w+[+-]\w+\b/', '"$0"', $text); 

Comments

Popular posts from this blog

matlab - Deleting rows with specific rules -

jquery - How would i go about shortening this code? And to cancel the previous click on click of new section? -