similiar like this example, php: remove brackets/contents from a string? i have no idea to replace
$str = '(ABC)some text'
into
$str = 'ABC';
currently use $str = preg_replace('/(.)/','',$str);
but not works. how to fix this?
similiar like this example, php: remove brackets/contents from a string? i have no idea to replace
$str = '(ABC)some text'
into
$str = 'ABC';
currently use $str = preg_replace('/(.)/','',$str);
but not works. how to fix this?
If you want to use replace, you could use the following:
The pattern will match the whole string, and replace it with whatever it found inside the parenthesis
Instead of preg_replace, I would use preg_match:
Try this:
I'd avoid using regex altogether here. Instead, you could use normal string functions like this: $str = str_replace(array('(',')'),array(),$str);