I am creating a minimal version of a text-to-markup process very similar to Textile. I successfully convert bold, italic, strikethroughs (with *, _ and - respectively), but I am also using the following expression to automatically convert HTTP strings to links:
/([^\(])(https?:\/\/([-\w\.]+)+(:\d+)?(\/([\w\/_\.\-]*(\?\S+)?)?)?)/
The problem is, if a HTTP string includes, for example, a dash, the expression for strikethroughs (/\-([^\*]+?)\-/
) is also processed, resulting in a URL link that would change:
site.com/path-with-dashes
to site.com/path<del>with</del>dashes
What is the best solution to achieve both processes together? I would assume that changing the strikethrough expression to require the character before the dash to be a space character, or the start of a line, would work, but I can't manage to achieve this in one expression.