From 2cb3f6f78234698b70fb057e888b5be513d30650 Mon Sep 17 00:00:00 2001 From: chengxl Date: Thu, 15 May 2025 15:35:07 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=AD=97=E7=AC=A6=E4=B8=B2?= =?UTF-8?q?=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/api/controller/Base.php | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/application/api/controller/Base.php b/application/api/controller/Base.php index ef79fa7..390c8a8 100644 --- a/application/api/controller/Base.php +++ b/application/api/controller/Base.php @@ -617,10 +617,29 @@ class Base extends Controller } + // public function blueIntegerChange($string){ + // return preg_replace_callback('/\[(\d+)\]/', function($matches) { + // var_dump($matches); + // return '[' . $matches[1] . ']'; + // }, $string); + // } + public function blueIntegerChange($string){ - return preg_replace_callback('/\[(\d+)\]/', function($matches) { - return '[' . $matches[1] . ']'; - }, $string); + + $pattern = '/\[(\d+)-(\d+)\]/'; + $replacement = '[\1–\2]'; // 使用反向引用 \1 和 \2 来保持数字不变,只替换中间的短横线 + $result = preg_replace($pattern, $replacement, $string); + + $result = preg_replace_callback('/\[-?\d+(?:,|,\s*\d+)?(?:–|\s*–\s*\d+)?\]<\/blue>/', function($matches) { + // if(!empty($matches[1])){ + // return '['.$matches[1].']'; + // } + return strip_tags($matches[0]); + }, $result); + $pattern = '/\[-?\d+(?:,|,\s*\d+)?(?:–|\s*–\s*\d+)?\]/'; + $replacement = '$0'; + $result = preg_replace($pattern, $replacement, $result); + return $result; } public function getBoardsForJournal($journal_id, $aar = false)