-2

I want to get string if the string not contain word "RAM".

String :
16/32/64 GB
2 GB RAM
32/64 GB
3 GB RAM
64 GB
4 GB RAM

And the result to be obtained :

String :
16/32/64 GB
32/64 GB
64 GB

What the regex pattern should be used? Please help me. Thank You.

1 Answers1

0
$str = '16/32/64 GB
2 GB RAM
32/64 GB
3 GB RAM
64 GB
4 GB RAM';
$pattern = '/\d+\sGB\sRAM/';
echo preg_replace($pattern, '', $str);
Seeyagain
  • 1
  • 2