Question: I see any examples of this, but all of than use the "device ready", I really need to use this event or I can get the device uuid out of this event?

When I tested this on my browser I got the gap of device uuid, but on device this don't show me anything.

Anyone Can show me an example?

Answer: 
Your solution will certainly work, but you can do it quicker with backreferences. I tested this and it works (you could make it a one-liner but it´s more readable this way) : 

```
pattern = r"CREATE TABLE `(.*?)`(.*?)ENGINE=.*?;"
replace_pattern = r"CREATE TABLE `\1`\2ENGINE=-myreplacedstring-\1;"
newdata = re.sub(pattern, replace_pattern, filedata, flags=re.DOTALL)

```

With :

* ´.\*?´ which is the non greedy version of ´.\*´
* ´\1´ is a backreference for the first capturing group for each occurence, which will be for example "tablename1", "tablename2" and so on
* the patterns as raw string with the prefix ´r´ (which is a good habit to
take)
* the re.DOTALL flag which allows "." to match newlines

I proposed before the following solution, which is wrong because look-behinds, signaled by "(?<=...)", must contain fixed length patterns :

```
pattern = r"(?<=CREATE TABLE `(.*?)`.*?ENGINE=).*;"
newdata = re.sub(pattern, '-myreplacedstring-\1', filedata)

```
Figured it out. Not sure how elegant or unbreakable this is, but it seems to work fine for my case(taking a mysql nodata dump, replacing engine with federated connection string, to easily create a full federated DB from one db to another).

```
import re

def gettablename(string, defaultstring):
    if 'CREATE TABLE' in string: 
        return re.search('`(.*)`', string).group(1)
    else: 
        return defaultstring

with open('dump.sql') as infile:
    tablename='def' # do i need this default?
    for line in infile:
        tablename=gettablename(line,tablename)
        line = re.sub('(?<=ENGINE).*;', '-myreplacedstring-'+tablename, line)
        print line

```