Regular expressions pcre2 · Using regex in tools

Rewrite text with sed

Swap two numbers around a hyphen, using capture groups in the replacement.

sed -E 's/([0-9]+)-([0-9]+)/\2-\1/' file.txt

Official Regular expressions pcre2 documentation

More using regex in tools commands

All using regex in tools commands · Regular expressions pcre2 cheatsheet

Was this page helpful?