I have those two lines of code written in python i want to convert them to php, please help i don't know how to do this in php.
#code in python:
vowels= re.compile(ur'[\u064B-\u0652]')
newstr = vowels.sub('', str)
thank you
I think this is equivalent:
<?php
$vowels ='/[\x{064B}-\x{0652}]/u';
$newstr = preg_replace($vowels,"",$str);
The string should be UTF-8 encoded.
I believe what you want is PHP's preg_replace(). I have no idea how PHP handles Unicode so I'm unsure if you can just take the Python pattern as-is and use it with PHP, but the syntax for using preg_replace() would be something like this:
<?php
$mystring = "jask;lfjalksdf"
$pattern = "/\u064B-\u0652/";
$replacement = "";
echo preg_replace($pattern, $replacement, $mystring);
?>
re.compile() means its compiling a regular expression. Look at this for some help.
The sub function is essentially adding str to the beginning of the regular expression.
More info on python regular expressions can be found here