Uppercase/lowercase modifiers in regex seem to not be supported
Author: mcilloniCreated Jun 11, 2020Updated May 20, 2026
LabelsC-enhancementA-regex
Both perl and sed support the \L and \U modifiers to convert a match to lowercase or uppercase respectively:
$ echo 'cat dog cow' | sed 's/\(dog\)/\U\1/'
cat DOG cow
$ echo 'cat dog cow' | perl -pE 's/(dog)/\U$1/'
cat DOG cowsd seems to not support the same syntax (probably it's a rust regex limitation?)
$ echo 'cat dog cow' | sd '(dog)' '\U$1'
cat \Udog cowCould sd perhaps optionally support pcre2 like ripgrep does, using a --pcre2 switch?
Source: chmln/sd