AngularBoy AngularBoy - 1 year ago 111
Javascript Question

how do i remove specific letters from alphabet string using regex

I have the alphabet as an uppercase string.

How do I remove the letters B G R P? I am using JavaScript.

I have tried:

replace(^/B/G/R/P/g, "")
replace(^[B,G,R,P]/g, "")

Answer Source

in php, would be somthing like this -

$remove = preg_replace('/[BGRP]/', '', $string); 
// new string 
echo $remove;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download