Update string.py

This commit is contained in:
Aqr-K
2025-08-30 08:59:35 +08:00
committed by GitHub
parent 26cc6da650
commit f22bc68af4

View File

@@ -945,8 +945,12 @@ class StringUtils:
自然排序
将字符串拆分为数字和非数字部分,数字部分转换为整数,非数字部分转换为小写字母
:param text: 要处理的字符串
:return 用于排序的数字和字符串列表
"""
if text is None:
return []
if not isinstance(text, str):
return [text]
text = str(text)
return [int(part) if part.isdigit() else part.lower() for part in re.split(r'(\d+)', text)]