$string = "ABC (Test1)";echo preg_replace("/([^)]+)/","",$string); // 'ABC '
preg_replace是基于Perl的正则表达式替换例程。该脚本的作用是匹配所有出现的右括号,后跟任意数量的字符 而不是
右括号,然后再次跟右括号,然后删除它们:
正则表达式细目:
/ - opening delimiter (necessary for regular expressions, can be any character that doesn't appear in the regular expression( - Match an opening parenthesis[^)]+ - Match 1 or more character that is not a closing parenthesis) - Match a closing parenthesis/ - Closing delimiter
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)