Delete Japanese Interlanguage Blank in Python

Asked 2 years ago, Updated 2 years ago, 38 views

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

2022-09-30 21:28

1 Answers

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.


2022-09-30 21:28

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.