NOTE: I'm not parsing lots of or html or generic html with regex. I know that's bad
TL;DR:
I have strings like
A sentence with an exclamation\! Next is a \* character
Where there are "escaped" characters in the original markup. I wish to replace them with their "originals". And get:
A sentence with an exclamation! Next is a * character
I have a small bit data that I need to extract from some wiki markup.
I'm only dealing with paragraphs/snippets here, so I don't need a big robust solution. In python, I tried a test:
s = "test \\* \\! test * !! **"
r = re.compile("""\\.""") # Slash followed by anything
r.sub("-", s)
This SHOULD yeild:
test - - test * !! **
But it doesn't do anything. Am I missing something here?
Furthermore, I'm not sure how to go about replacing any given escaped character with its original, so I would probably just make a list and sub with specific regexes like:
\\\*
and
\\!
There's probably a much cleaner way to do this, so any help is greatly appreciated.