Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
RE output clarity
#1
Hi

I'd like to know why the output is only ['a'], instead of ['a', 'b', 'a'].
I thought that the presence of "|" would mach either a or b.
The presence of "+" is 1 or more, so I thought that it would attempt to match
all of "aba" as a result.

>>> import re
>>> re.findall(r'(a|b)+', 'aba')
['a']
Am using 3.6.5.
Reply


Messages In This Thread
RE output clarity - by bluefrog - Jun-09-2018, 11:36 AM
RE: RE output clarity - by snippsat - Jun-09-2018, 12:41 PM
RE: RE output clarity - by killerrex - Jun-09-2018, 01:04 PM
RE: RE output clarity - by bluefrog - Jun-10-2018, 07:03 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020