简体   繁体   中英

Javascript Regular Expression Code to PHP Regular Expressions ?

I have following java script regular expression which i need to convert to similar php converter.

text = text.replace(/R/g, "ූ");

Can someone help me to convert this into PHP ?

its regex counterpart in php will be :

preg_replace( '/R/', 'your replacement string', $text );

$text = the value of 'text' in your javascript code.

However, for simple text replace, regular expressions are expensive. If your problem can't be solved using simple string functions then only use regex.

It's very similar:

$text = preg_replace('/R/', "ූ", $text);

Have look at the preg_replace documentation .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM