मुझे नहीं पता कि यह चीजें और अधिक स्पष्ट करेंगी, लेकिन आइए हम यह कल्पना करने की कोशिश करें कि एक साधारण तरीके से हुड के नीचे क्या होता है, हम मिलान करने के लिए क्या होगा।
# group(0) return the matched string the captured groups are returned in groups or you can access them
# using group(1), group(2)....... in your case there is only one group, one group will capture only
# one part so when you do this
string = 'abcdla'
print(re.match('(ab|cd)', string).group(0)) # only 'ab' is matched and the group will capture 'ab'
print(re.match('(ab|cd)+', string).group(0)) # this will match 'abcd' the group will capture only this part 'cd' the last iteration
findallउसी समय स्ट्रिंग का मिलान करें और उसका उपभोग करें, आइए कल्पना करें कि इस REGEX के साथ क्या होता है '(ab|cd)':
'abcdabla' ---> 1: match: 'ab' | capture : ab | left to process: 'cdabla'
'cdabla' ---> 2: match: 'cd' | capture : cd | left to process: 'abla'
'abla' ---> 3: match: 'ab' | capture : ab | left to process: 'la'
'la' ---> 4: match: '' | capture : None | left to process: ''
--- final : result captured ['ab', 'cd', 'ab']
अब उसी के साथ '(ab|cd)+'
'abcdabla' ---> 1: match: 'abcdab' | capture : 'ab' | left to process: 'la'
'la' ---> 2: match: '' | capture : None | left to process: ''
---> final result : ['ab']
मुझे उम्मीद है कि यह बात थोड़ी साफ हो जाएगी।