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

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -