I am a beginner for the regular expressions pattern matching in python. please help me to solve this problem.
I want to extract some texts from the given string. Please check the below example.
String : "keyword//match1/match2/more_text_with_/_more_and_more_/_texts"
I need to extract "match1" and "match2"
I wrote the following python code to do that...
import re
astr = 'keyword//match1/match2/more_text_with_/_more_and_more_/_texts'
match = re.search('keyword//(.*)/(.*)/.*', astr)
print("match1 : ", match.group(1))
print("match2 : ", match.group(2))
The result is...
match1 : match1/match2/more_text_with_
match2 : _more_and_more_
I read about "How Regex Engine Works" from here https://www.regular-expressions.info/engine.html
And I can understand why this result comes. But I have no idea to write a regular expression to get my required matching texts.
Please help me with this.
Thank you very much,