修改字符串方法
This commit is contained in:
@@ -617,10 +617,29 @@ class Base extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// public function blueIntegerChange($string){
|
||||||
|
// return preg_replace_callback('/\[(\d+)\]/', function($matches) {
|
||||||
|
// var_dump($matches);
|
||||||
|
// return '<blue>[' . $matches[1] . ']</blue>';
|
||||||
|
// }, $string);
|
||||||
|
// }
|
||||||
|
|
||||||
public function blueIntegerChange($string){
|
public function blueIntegerChange($string){
|
||||||
return preg_replace_callback('/\[(\d+)\]/', function($matches) {
|
|
||||||
return '<blue>[' . $matches[1] . ']</blue>';
|
$pattern = '/\[(\d+)-(\d+)\]/';
|
||||||
}, $string);
|
$replacement = '[\1–\2]'; // 使用反向引用 \1 和 \2 来保持数字不变,只替换中间的短横线
|
||||||
|
$result = preg_replace($pattern, $replacement, $string);
|
||||||
|
|
||||||
|
$result = preg_replace_callback('/<blue>\[-?\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 = '<blue>$0</blue>';
|
||||||
|
$result = preg_replace($pattern, $replacement, $result);
|
||||||
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getBoardsForJournal($journal_id, $aar = false)
|
public function getBoardsForJournal($journal_id, $aar = false)
|
||||||
|
|||||||
Reference in New Issue
Block a user