chmln / sd

Intuitive find & replace CLI (sed alternative)
MIT License
5.79k stars 136 forks source link

"[^[]]" -- "unclosed character class" #304

Closed greg-minshall closed 2 hours ago

greg-minshall commented 2 hours ago

hi. i'm not a regex expert. but, i think in the above, the second [ should not be considered a character class bracket, but rather just a character. cheers.

❯ echo foo | sd '\[\[[^[]*\]\[[^]]*\]\]' x
error: invalid regex regex parse error:
    \[\[[^[]*\]\[[^]]*\]\]
          ^^
error: unclosed character class
❯ echo foo | sd '\[\[[^\[]*\]\[[^]]*\]\]' x
foo
greg-minshall commented 2 hours ago

oops. rtfm -- i looked at the Rust regex. sorry.