I know this question has been asked many times in different versions, but i did not find anything that helped me. 

I have a list of words: 

```
arr = ["id",...]

```

And I have several strings: 

```
str = "my_id"
str1 = "Id_number"
str2 = "my_id_rocks"
str3 = "my_idea"

```

Im trying to find the word "id" in the strings and turn in to upper case. but if `id` is a part of a word in the string, then do nothing. Meaning after I apply the function Ill get :

```
str = "my_ID"
str1 = "ID_number"
str2 = "my_ID_rocks"
str3 = "my_idea"

```

I cannot assume anything about the strings, some letters can be upper case, some lower case.

So far this is what i have, but this also capitalizes `idea => IDea` which i dont want:

```
def words_to_upper(str):
    words = ["id"]
    for word in words:
        if word in str.lower():
            replace_word = re.compile(re.escape(word), re.IGNORECASE)
            str = replace_word.sub(word.upper(), str)
            break
    return str

```

Thank you.