mahen3d
mahen3d

Reputation: 7734

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 ?

Upvotes: 0

Views: 79

Answers (2)

DrGeneral
DrGeneral

Reputation: 2132

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.

Upvotes: 1

Toto
Toto

Reputation: 91385

It's very similar:

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

Have look at the preg_replace documentation.

Upvotes: 1

Related Questions