jqlang / jq

Command-line JSON processor
https://jqlang.github.io/jq/
Other
29.59k stars 1.54k forks source link

The code example for trim ltrim and rtrim from the manual do not work #3127

Closed riknor closed 1 month ago

riknor commented 1 month ago

This example from the manual do not work https://jqplay.org/jq?q=trim%2C%20ltrim%2C%20rtrim&j=%22%20abc%20%22

image

wader commented 1 month ago

Hello, dup of https://github.com/jqlang/jq/issues/3078 and probably another reason why the online documentation should point to the latest release instead of development version 🤔

If you need a trim function in latest stable release you can define one something like this:

$ jq -n 'def trim: capture("^\\s*(?<s>.*?)\\s*$"; "m").s; " abc " | trim'
"abc"