Merge branch 'feature/mzl_dev'
# Conflicts: # app/command/TbCommand.php # app/common/utils/email/Emails.php # app/controller/IndexController.php # app/functions.php
This commit is contained in:
@@ -194,4 +194,30 @@ if (!function_exists('InquiryFormat')) {
|
||||
$content .= '内容:'.$data['content'];
|
||||
return $content;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除字符串中的括号及其内部内容(仅移除第一个匹配项)
|
||||
*
|
||||
* @param string $str 要处理的字符串
|
||||
* @return string 处理后的字符串
|
||||
*/
|
||||
if (!function_exists('removeParentheses')) {
|
||||
function removeParentheses(string $str): string
|
||||
{
|
||||
// 匹配模式:半角括号或全角括号及其内部内容
|
||||
$pattern = '/
|
||||
(?: # 非捕获分组开始
|
||||
\( # 匹配半角左括号
|
||||
[^)]* # 匹配除半角右括号外的任意字符
|
||||
\) # 匹配半角右括号
|
||||
)|(?: # 或
|
||||
\( # 匹配全角左括号
|
||||
[^)]* # 匹配除全角右括号外的任意字符
|
||||
\) # 匹配全角右括号
|
||||
) # 非捕获分组结束
|
||||
/xu'; // x: 忽略空白 u: Unicode模式
|
||||
|
||||
return trim(preg_replace($pattern, '', $str, 1));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user