Python beginner asks a question about regular expressions crying

Asked 2 years ago, Updated 2 years ago, 13 views

c = 'Namae Beach (Namae 1, 3-ri) (Namae Beach (Namae 1, 3-ri))'
d = re.compile('.+(?=())'))
print(d)

Using the regular expression as shown in the picture, the first (in front) I just want to pull out Namae Beach..

I'm trying to solve it by searching the front, but there's an error, is there a solution?

a = Samjin Fish Cake History Museum [Busan Fish Cake Museum] (Samjin Fish Cake Experience History Museum [Busan Fish Cake Exhibition Hall])

I only want to extract Samjin Fish Cake History Museum [Busan Fish Cake Museum] from a.

As with the first question (I tried to solve it with a forward search, but it didn't work

I'm trying to make a code to print it out using re.sub, but it's not working well.

Master, please

python

2022-09-21 22:11

1 Answers

I don't think the error is in parentheses.

It feels like I'm forcing myself to do it, but... Please refer to it and make the appropriate expression....

import re 


c = 'Namae Beach (Namae 1, 3-ri) (Namae Beach (Namae 1, 3-ri))'
d = re.compile('(^[^\(]+).(?=\()')
f = d.findall(c)

print(d.match(c).group())


2022-09-21 22:11

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.