I have an input like this test1.test2.part01
which I want to strip away to test1.test2
. The only thing i know is that it will end with partxx
and probably a dot before the partxx
. However, it will not always be a apart. Another example of input might be testas1.tlp2.asd3.part10
which ofcourse should be stripped to testas1.tlp2.asd3
.
I've made all that, no problem. The problem is the dot at the end before partxx
. My regex at the moment is:
(.*)\.?part\d{1,2}
But it will include the dot in the group. I do not want the dot to be in the group. The below works as I want it, given that the dot exists, but it will not always be there.
(.*)\.part\d{1,2}
How can I exclude the optional dot from the group?