4 ms·
jq has string interpolation too, so it can even get a little bit nicer: "<option value=\"/examples/\(.)/\">\(.)</option>"
by mpalmer 3y ago
jq has string interpolation too, so it can even get a little bit nicer:
"<option value=\"/examples/\(.)/\">\(.)</option>"
- mdaniel 3y agoYeah, but muscle memory bites me all the time and I put the backslash on the closing paren, too, because I'm so used to the regex usage of that syntax which needs them to match I also want to draw the reader's attention to the magic of |@uri <https://github.com/jqlang/jq/blob/jq-1.7/docs/content/manual/manual.yml#L2097 https://github.com/jqlang/jq/blob/jq-1.7/docs/content/manual...> for a bunch of cases, but doubly so in TFA's case where they're plugging strings into a URI context. Simple string concat often works great for "hello world", but the world is not always just hello, so one quick use of the filter and jq's got your back echo "the world's scary" | jq -Rr '"<option value=\"/examples/\(.|@uri)\">\(.)</value>"'