Question: Example strings:

`myString1 = "/desktop/2512754353/Screenshots/photo_0000.png"`

`myString2 = "/desktop/51232132561/Screenshots/photo_3501.png"`

`myString3 = "/desktop/12321516123/Screenshots/photo_7501.png"`

`myString4 = "/desktop/5234324324/Screenshots/photo_11501.png"`

I had a look around, and couldn't really figure out a proper way to do this. I want to be able to also retrieve the last numbers of my strings after the **photo\_** part, and store them in another variable (string, not int or float). Furthermore, I don't need the number before **/Screenshots**. It would also be nice if it can work for any number length. The **photo\_** will always remain inside the string too.

Answer: 
You can write a regex that only matches the end of the string

```
>>> import re
>>> myString1 =  "/desktop/2512754353/Screenshots/photo_0000.png"
>>> re.search(r"photo_(\d+)\.png$", myString1).group(1)
'0000'

```
I suggest:

```py
import re

myString3 =  "/desktop/12321516123/Screenshots/photo_7501.png"
s = re.findall('\_\d+',myString3)[0]
int(s[1:len(s)])

```

> 
> output: 7501
> 
> 
>