Separation of Korean and English

Asked 2 years ago, Updated 2 years ago, 23 views

I want to separate it as follows, what should I do??? I can only think of using reGex in the order of English, Korean, and numbers, but I think there is a better way, so I ask for your advice.

# Example
a = 'asdf is meadfe23245'
# the desired result
["asdf", "Ganadara", "adfe", "23245"]

# one's thoughts
b = ["[a-z]+", "[ga-he]+", "[0-9]+"]]
c = []
for i in b:
    d = re.findall(i, a)
    c += d
# ["asdf" "adfe", "Ganadara", "23245"]

python

2022-09-20 08:40

1 Answers

I think you can do it like now.

You must turn the double loop of fori in a:fori in b:. Check which i you checked last time matches which r and which i you are checking this time matches which r. Only if the r matched by the two i are different, the characters you have memorized so far will be added to c and will be remembered anew from this i.

If you look at it after writing it down, it looks very complicated, but it's actually a simple story. When we glanced at asdf Daadfe23245 with our eyes, asdf and could break Da Da Da because in fact, we read it sequentially from a and then suddenly noticed that appeared.

If I were to code it, there wouldn't be any inconveniences, but this should be enough. Fighting!


2022-09-20 08:40

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.