Thank you both for the input.
The thing is that the string I search for will not always be located before * and be two strings long. For example, the ID can be AmnCarrotbreadPrime and word bread would be the word I search for. I really think I need to loop through table 2 using DAX or M code if possible. Otherwise, I am planning to write a VBA to prepare the data before importing it in Power Query.