I want to exclude the as
word from abc.id as od
using preg_match();
Could anyone help me what will be the pattern?
Desired result is:
abc.id
asod
Hightlighed as the selection and as
is excluded from search.
You can use the following regex pattern to select the string :
(.*?)(?:\sas\s)(.*?)$
input >> abc.id as od
regex search >> (.*?)(?:\sas\s)(.*?)$
replace with >> $1$2
output >> abc.idod
PHP
$re = '/(.*?)(?:\sas\s)(.*?)$/';
$str = 'abc.id as od';
$subst = '$1$2';
$result = preg_replace($re, $subst, $str);
echo $result;