Skip to content

Commit

Permalink
docs: Add a comment for extract_alphanumeric
Browse files Browse the repository at this point in the history
  • Loading branch information
teihenn committed Jan 13, 2025
1 parent fcbec33 commit 208ff34
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/basic/string.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())

0 comments on commit 208ff34

Please sign in to comment.