Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
195 views
in Technique[技术] by (71.8m points)

python - Regular expression to return text between parenthesis

u'abcde(date='2/xc2/xb2',time='/case/test.png')'

All I need is the contents inside the parenthesis.

question from:https://stackoverflow.com/questions/65650527/function-should-return-the-contents-of-the-parentheses-if-no-text-appears-in-pa

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

If your problem is really just this simple, you don't need regex:

s[s.find("(")+1:s.find(")")]

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...