String building with regex
Question: So I am fairly new to python and am only self taught in this particular
language, but I have hit a bit of a snag.

What I am trying to do is build a string that has with in it a digit that can
be of any length or pattern. For example:

    
    
       "Data_image_%s.%d" %(myStr, r'[0-9]+') 
       # Well, this won't actually work since %d is expecting an integer,
       # but you get the idea.
    

When I do this I get back

    
    
    Data_image_picture.[0-9]+.png
    

The ultimate objective is to create a string that reads like:
`Data_image_picture.1234567.png`

Any thoughts on how I might go about correcting this?

Edit: What I am trying to do is take images off my companies website but the
image url is dynamic depending on who and when the images are loaded to the
browser. So the format is typically "data_image_Joe_session#id.png

Edit 2: I think I have been going about this problem the wrong way, I'll
likely need to parse through the data to figure what string patterns I need,
instead of creating a one size fits all string like I have been doing.

Thank you for your time and help


Answer: Regular expressions are used for _matching_ , not for building strings or
building random numbers.

To build a string with a random number between 0 and 9999999 you could do
something like:

    
    
    from random import random
    
    myStr = "Data_image_picture." + str(int(random()*10000000)) + ".png"
    

