Regular Expression matching a phrase and everything up to but not including the next match?

15 views Asked by At

I've been trying to use regular expression to simplify a text parser for my job. But I am running into issues when trying to capture two matches in the same line.

The match I am trying to capture would look something like this when read in Python.

> 12.1 Text I need to capture24.11.51 Text I need to capture

I have been using the pattern '\d{1,2}[.]\d{1,2}([.]\d{1,2})? \D(.*)' to match with just the numbers and capture everything after it per line, but I am stumped on how to avoid capturing the second.

I have seen on other answers, they are always matching the same phrase multiple times, I am not sure how you would do it when the phrase to match is not an exact copy.

Any help would be appreciated!

0

There are 0 answers