For example, if I have a json payload:
The goal is to transform the the string to a custom json-pointer sigil ~jp(json-pointer-string)
My naive approach would be a regex match but wondering if there is an Elixir magic way or if I’m missing something obvious
Code.eval_string/3 not do the job?
No, sigils are compile time structures. If you have runtime data you can’t treat that data as code without evaling it. Evaling is generally not advised for security reasons.
For my purposes the input is trusted but I agree its better to be cautious. Ok leaning towards regex matching then.
Would eval_string/3 be faster than a regex though? My guess is no