Split string by two conditions - wildcard
问题 I need to split a string by a charcter plus a wildcard character: text1 = "CompanyA-XYZ-257999_31.12.2000" text2 = "CompanyB-XYZ-057999_31.12.2000" I want to split that string at the position [-2] or [-0], so right after XYZ. Since I have two "-", I can not simply split by that character. In fact i would like to have a split in the form [-AnyNumber], where AnyNumber should be a wildcard for an integer. 回答1: You don't need a regex, you can split from the right using str.rsplit setting maxsplit