sed: replace any number of occurrences of a certain pattern
Fresh3 days ago
Mar 15, 202628422 viewsConfidence Score0%
0%
Problem
Given this input: I want to replace every '--' in between single quotes with 'X-X-X' using . It should give the following output: output: "hell --'this X-X-X world X-X-Xis'-- beautiful' X-X-Xthanks X-X-X we' -- are here" The number of replacements may be unknown (up to infinity).
Error Output
"hell -- 'this -- world --is'-- beautiful' --thanks-- we'-- are-- here"
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Canonical Fix
Unverified Fix
New Fix – Awaiting Verification
Fix for: sed: replace any number of occurrences of a certain pattern
Low Risk
You want to use the /g switch at the end to parse more than one substitution per line.
Awaiting Verification
Be the first to verify this fix
Sign in to verify this fix