I'm trying to write a regex that replaces any markdown specific character (to be escaped, [\*_{}[\]()#+\-.!`]) not inside single or triple backticks. This is being implemented in Javascript. A couple examples:
foo `bar` baz.qux `quux`-> should replace.inbaz.quxwith\\.&foo `bar.baz` foo_bar-> should replace_with\\_&infoo_bar, but not.inbar.baz
This is what I have right now: markdown.replace(/[\\*_{}[\]()#+\-.!`]/g, '\\$&'), but it matches . in `foo.bar`.
Thanks in advance for the help!