From 208ff34306bdc72974713e637494bb86fec8d6cb Mon Sep 17 00:00:00 2001 From: teihenn Date: Mon, 13 Jan 2025 14:50:01 +0900 Subject: [PATCH] docs: Add a comment for extract_alphanumeric --- src/basic/string.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/basic/string.py b/src/basic/string.py index c69b706..eb5b4c1 100644 --- a/src/basic/string.py +++ b/src/basic/string.py @@ -38,6 +38,7 @@ def extract_alphanumeric(s: str) -> str: >>> extract_alphanumeric("こんにちは123ABCワールド") '123ABC' """ + # isalnum() alone would include Unicode alphanumeric characters (like '12345' or 'ABCDE') # isascii() ensures we only get ASCII characters (0-127), # excluding Unicode characters like Japanese, Emoji, etc. return "".join(c for c in s if c.isascii() and c.isalnum())