I asked you a similar question in JavaScript before, but what is the description in Python?
·Language
Python (Python 3)
·What you want to do
I want to remove only the spaces between Japanese and English characters.
·Example
Input: Taro Tanaka is a Japanese boy.
Output: Taro Tanaka is Japanese boy.
Thank you for your cooperation.
python python3
I am a contributor.
I have solved it myself, so I will write my answer here.Excuse me.
import re
str="Taro Tanaka is Japanese boy."
result=re.sub('([Ahn 1- -])\s+(?=[Ahn 1- -]))')',r'\1\2',str)
print(str)
print(result)
Run Results
Taro Tanaka is a Japanese boy.
There is an example sentence called Taro Tanaka is Japanese boy.
© 2025 OneMinuteCode. All rights reserved.