Skip to main content
added 317 characters in body
Source Link
Avinash Raj
  • 175.3k
  • 32
  • 247
  • 289

Your regex would be,

(\d+)\s(\d+)\s([^\.]*)

DEMO

Your python code would be,

>>> s = "STRING 1 160 Some descriptor information. /Uselessstuff.; STRING 161 274 Some other descriptor information. /Moreuselessstuff.; STRING 275 1070 Last descriptor info. /Lastuselesspart."
>>> m = re.findall(r'(\d+)\s(\d+)\s([^\.]*)', s)
>>> m
[('1', '160', 'Some descriptor information'), ('161', '274', 'Some other descriptor information'), ('275', '1070', 'Last descriptor info')]

Explanation:

  • (\d+) Captures one or more digits into a group.
  • \s Above captured digits would be followed by a space.
  • (\d+) Again one or more digits are captured into second group.
  • \s Followed by a single space.
  • ([^\.]*) Captures any character not of a literal dot zero or more times.

Your regex would be,

(\d+)\s(\d+)\s([^\.]*)

DEMO

Your python code would be,

>>> s = "STRING 1 160 Some descriptor information. /Uselessstuff.; STRING 161 274 Some other descriptor information. /Moreuselessstuff.; STRING 275 1070 Last descriptor info. /Lastuselesspart."
>>> m = re.findall(r'(\d+)\s(\d+)\s([^\.]*)', s)
>>> m
[('1', '160', 'Some descriptor information'), ('161', '274', 'Some other descriptor information'), ('275', '1070', 'Last descriptor info')]

Your regex would be,

(\d+)\s(\d+)\s([^\.]*)

DEMO

Your python code would be,

>>> s = "STRING 1 160 Some descriptor information. /Uselessstuff.; STRING 161 274 Some other descriptor information. /Moreuselessstuff.; STRING 275 1070 Last descriptor info. /Lastuselesspart."
>>> m = re.findall(r'(\d+)\s(\d+)\s([^\.]*)', s)
>>> m
[('1', '160', 'Some descriptor information'), ('161', '274', 'Some other descriptor information'), ('275', '1070', 'Last descriptor info')]

Explanation:

  • (\d+) Captures one or more digits into a group.
  • \s Above captured digits would be followed by a space.
  • (\d+) Again one or more digits are captured into second group.
  • \s Followed by a single space.
  • ([^\.]*) Captures any character not of a literal dot zero or more times.
Source Link
Avinash Raj
  • 175.3k
  • 32
  • 247
  • 289

Your regex would be,

(\d+)\s(\d+)\s([^\.]*)

DEMO

Your python code would be,

>>> s = "STRING 1 160 Some descriptor information. /Uselessstuff.; STRING 161 274 Some other descriptor information. /Moreuselessstuff.; STRING 275 1070 Last descriptor info. /Lastuselesspart."
>>> m = re.findall(r'(\d+)\s(\d+)\s([^\.]*)', s)
>>> m
[('1', '160', 'Some descriptor information'), ('161', '274', 'Some other descriptor information'), ('275', '1070', 'Last descriptor info')]