💻 Software
Print back-reference in regular expression
Fresh7 days ago
Mar 15, 20269019 viewsConfidence Score0%
0%
Problem
I was hoping for a way to make sed replace the entire line with the replacement (rather than just the match) so I could do something like this: and have it only print the back-reference. From this question, it seems like the way to do it is mess around with the regex to match the entire line, or us…
Error Output
sed -e "/$some_complex_regex_with_a_backref/\1/"
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Canonical Fix
Unverified Fix
New Fix – Awaiting Verification
Fix for: Print back-reference in regular expression
Low Risk
I don't know sed well enough to answer, but if you are flexible and use grep: or The --only-matching (or the short form -o) flag tells grep to print out just the matched part, not the whole line.
Awaiting Verification
Be the first to verify this fix
Sign in to verify this fix