0
Test String: "Version 3.1.A"

RegEx: "(\d\.){2}."

Returning: [('1.3.A', '3.')]

Why does this return 2 matches, the second only matches a non-reoccuring (\d.)

Is there a way I can force only the complete match (1.3.A) to return using the {*} operator (not explicit \d.\d..)

LazyMoggy
  • 194
  • 3
  • 14

1 Answers1

1

By using a non-capturing group you can get what you want, like the following:

>>> import re
>>> text = "Version 3.1.A"
>>> re.findall(r"((?:\d\.){2}.)", text)
['3.1.A']
dcg
  • 3,856
  • 1
  • 15
  • 27