From fd5b592253d12e7e58ab67d1ef7b523e831fb360 Mon Sep 17 00:00:00 2001 From: Gregory Date: Sun, 23 Dec 2018 19:44:57 -0500 Subject: [PATCH] Add struggles --- README.md | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index b169882..ecb20a0 100644 --- a/README.md +++ b/README.md @@ -18,13 +18,15 @@ Find & replace expressions are split up and in most cases unescaped, which contr ## Comparison to sed -Although `sed` has a nice regex syntax with `-r`, it is not portable and doesn't work on, say, MacOS or Solaris. Also, `sed` is far more powerful. Focusing on just finding and replacing allows `sd` to make this common task far more straightforward. - Some cherry-picked examples, where `sd` shines: - Replace newlines with commas: - - `sed ':a;N;$!ba;s/\r/,/g'` vs - - `sd -r '\r' ','` - - + - sed: `sed ':a;N;$!ba;s/\r/,/g'` vs + - sd: `sd -r '\r' ','` +- Extracting stuff out of strings with special characters + - sd: `echo "{((sample with /path/))}" | sd -r '\{\(\(.*(/.*/)\)\)\}' '$1'` + - sed + - incorrect, but closest I could get after 15 minutes of struggle + - `echo "{((sample string also contains /path/))}" | sed 's/{((\.\*\(\/.*\/\)))}/\1/g'` +Note: although `sed` has a nicer regex syntax with `-r`, it is not portable and doesn't work on, say, MacOS or Solaris.