I am trying to write a javascript regex only matching NASM-style comments in HTML. For example, matching "; interrupt" for "INT 21h ; interrupt".
You may know /;.*/ can't be the answer because there can be a HTML entity before the comment; I thought /(?:[^&]|&.+;)*(;.*)$/ should work for it, but I found it has two problems:
" ; hello world".match(/(?:[^&]|&.+;)*(;.*)$/)is an array[" ; hello world", "; hello world"]. I don't want an array." ; hello world; a message".match(/(?:[^&]|&.+;)*(;.*)$/)is[" ; hello world; a message", "; a message"]; even worse the second element.
Question:
- Why is
(?:)block returned? - Why
"; a message", not"; hello world; a message"? - What's the right regex I can use?