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
- Search with grep
- Use lookarounds with grep
- Match in JavaScript
- Replace in JavaScript
- Find all matches in Python
- Replace in Python
All using regex in tools commands · Regular expressions pcre2 cheatsheet