Post History
When running sed through fish, I often encounter a problem with regexes. Many commonly used regex control characters like []{}().+ need to be escaped, even if I type the regex in a single quoted st...
#1: Initial revision
Can I enter raw strings in fish to avoid escaping regexes for sed?
When running `sed` through `fish`, I often encounter a problem with regexes. Many commonly used regex control characters like `[]{}().+` need to be escaped, even if I type the regex in a single quoted string. For example: ``` $ echo abc | sed 's/b+/X/' abc $ echo abc | sed 's/b\+/X/' aXc ``` This constant `\` in front of many characters makes my regexes absolutely unreadable. It gets even worse if the regex itself needs to escape characters, the whole thing becomes a jumble of backslashes. Surely there's a better way to enter complex strings in the shell? I don't know if this is a fish problem, or a generic shell problem, or a sed problem, but I would love to know how to avoid it. As an example of what I expect: Python has an elegant solution to this, called "raw strings". `r"b+"` is therefore interpreted without any formatting or templating at all. Is there a raw string option in fish, or other shells? Does sed have an alternate input mode to get around this annoying problem?