Php code to replace brackets in a particular text
You may be faced with a situation to remove text inside the bracket,wonder how it can be done.. it can be easily done by preg_replace function
Here is the preg_replace function code to replace text inside brackets(along with brackets)by freespace
$text1=preg_replace("/(\([A-Za-z0-9.',()]+)\)/si”,”",$text);
Explanation of the code:
a)First ‘/’ and ‘/’ are delimiters
b)’(' - this stats the replacing text should start with ‘(’
c)After thna grouping starts with ‘(’ and ‘)’
d) ([A-Za-z0-9.',()]+ - This code states tha matching code can contain any number of A-Z,a-z,0-9,. , ‘,’,(,) characters
e)Grouping ends with ‘)’
f)delimiters are followed by ‘i’ and ’s’ which indicates that text is case insensitive