in `|^|~` `^` matches line start creating infinite loop, it needs to be escaped
`++` `--` need to be at start
| and & should be `\|\|?|&&?`
also it will be better to use regular expression
`regex: /\+\+|--|[!]/` to make this more readable