Where can I find docs related to interpolation syntax?

I have a question of where I can find docs/resources related to what I think is ecto's interpolation syntax. I was trying to find a contains function or something similar for an ecto query and found this gem in Stack Overflow.

|> where([p], like(p.title, ^"%#{String.replace(term, "%", "\\%")}%"))

I have tried to find the interpolation syntax for this, ^"%#{String.replace(term, "%", "\\%")}%"), but can’t seem to find any cheat sheet for it. For example, why % at the beginning and end? I have seen the % at the beginning so I thought that meant begins with or something.

Any recommendations would be appreciated. I plan on creating a doc or contributing back to Ecto if we can crowd source an answer here as well.

Hi :wave:

This is actually Elixir basic String interpolation, the "#{...}", and inside the interpolation the author is replacing any % in term with its escaped version \%. Why replace it? Because the query will perform a LIKE operation. The basic gist of like is that: % in the beginning represents anything before the pattern, and % at the end is anything after the pattern, so in this case the author is executing something like a “contains” operation.

Here are some examples:

database value like input found?
Elixir “%xir” true
Function “Fun%” true
Google “%oo%” true

Thanks! Didn’t realize it was a postgres idiom. I need to read up more on postgres syntax.