Why does 1821 only match twice?

Since the regular expression is looking for [0-9][0-9], why wouldn't it match for ['18,' 82', '21'] instead of just ['18', '21']?

Same with 12345, which I thought would result in ['12', '23', '34', '45']

asked 08 Jan, 20:48

Forhavu's gravatar image

Forhavu
561

accept rate: 0%


One Answer:

12

From the python documentation for re.findall: "Return all non-overlapping matches of pattern in string, as a list of strings. " (emphasis added).
So I guess the answer is that that is the spec for the function.

link

answered 13 Jan, 01:23

Joe%20Foran's gravatar image

Joe Foran
2877

Your answer
Question text:

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags

×3,907
×377
×8

Asked: 08 Jan, 20:48

Seen: 215 times

Last updated: 13 Jan, 01:23